<div dir="ltr"><div dir="ltr" class="gmail_msg">Good starting point for this conversation, Lari. When I wrote the patches for an /acquisitions/vendors endpoint (18120 / NSO) [1] the first thing I noticed was column/property names were inconsistent, some where not used at all, etc. So I wrote a couple functions (_to_api and _to_model) to deal with back and forth data transformation. I will of course file a bug proposing to rename the columns, and remove unused ones. But in the meantime, this major refactoring shouldn't halt the REST api development.</div><div dir="ltr" class="gmail_msg"><br></div><div class="gmail_msg">I am all for using names that are not tied to our legacy names in the code, specially when we have consensus on the rename (patrons, holds and libraries are clear examples). It is not trivial (or even worth) renaming borrowernumber columns in the code, but I think we have the chance to expose a consistent API and we need to do do the effort.</div><div dir="ltr" class="gmail_msg"><br></div><div class="gmail_msg">So,</div><div class="gmail_msg">+1 patron_id (borrowernumber means nothing on the API, as it all refers to patrons)<br></div><div class="gmail_msg">+1 library_id (branchcode, same as above)</div><div dir="ltr" class="gmail_msg"><br></div><div class="gmail_msg">Kind regards.</div><div dir="ltr" class="gmail_msg"><br></div><div dir="ltr" class="gmail_msg">[1] <a href="https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=18120">https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=18120</a></div><br class="gmail_msg"><div class="gmail_quote gmail_msg"><div dir="ltr" class="gmail_msg">El vie., 24 mar. 2017 a las 10:23, Taskula Lari (<<a href="mailto:lari.taskula@jns.fi" class="gmail_msg" target="_blank">lari.taskula@jns.fi</a>>) escribió:<br class="gmail_msg"></div><blockquote class="gmail_quote gmail_msg" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hello fellow Koha devs,<br class="gmail_msg">
<br class="gmail_msg">
As the REST API is moving forward, me and Tomás had a discussion on<br class="gmail_msg">
parameter and object property naming convention and how we should expose<br class="gmail_msg">
column names to API consumers. Since we have already renamed multiple<br class="gmail_msg">
objects in Koha (e.g. borrowers -> patrons, branches -> libraries etc),<br class="gmail_msg">
we should discuss naming convention in REST API and maintain a<br class="gmail_msg">
consistency throughout.<br class="gmail_msg">
<br class="gmail_msg">
For those who have not been following REST API development, I will<br class="gmail_msg">
quickly brief the current method that most REST API patches in Bugzilla<br class="gmail_msg">
have implemented: The endpoint name in most cases uses name of the<br class="gmail_msg">
corresponding Koha-object, for example /api/v1/patrons, /api/v1/holds,<br class="gmail_msg">
/api/v1/cities and so on. This is pretty clear. We then fetch one or<br class="gmail_msg">
more rows from the database via Koha-objects and simply convert them<br class="gmail_msg">
into JSON.<br class="gmail_msg">
<br class="gmail_msg">
The issue is that many of our database tables have inconsistency between<br class="gmail_msg">
column names and the Koha-object names - meaning that currently<br class="gmail_msg">
/api/v1/patrons returns a borrowernumber, /api/v1/holds a reserve_id and<br class="gmail_msg">
so on. The API user does not care how we internally call our objects and<br class="gmail_msg">
its parameters but only wants to see a clear and consistent naming<br class="gmail_msg">
convention. Therefore /api/v1/patrons should return a "patron_id",<br class="gmail_msg">
"library_id".<br class="gmail_msg">
<br class="gmail_msg">
Do we want this? What about implementation, how do we want Koha-objects<br class="gmail_msg">
to work with this? Koha::Object currently contains a TO_JSON method that<br class="gmail_msg">
could be suitable for outputting renamed keys. What about input when the<br class="gmail_msg">
keys are renamed, how do we want to convert them back? Any other<br class="gmail_msg">
comments or ideas?<br class="gmail_msg">
<br class="gmail_msg">
Lari Taskula<br class="gmail_msg">
Koha-Suomi Oy<br class="gmail_msg">
_______________________________________________<br class="gmail_msg">
Koha-devel mailing list<br class="gmail_msg">
<a href="mailto:Koha-devel@lists.koha-community.org" class="gmail_msg" target="_blank">Koha-devel@lists.koha-community.org</a><br class="gmail_msg">
<a href="http://lists.koha-community.org/cgi-bin/mailman/listinfo/koha-devel" rel="noreferrer" class="gmail_msg" target="_blank">http://lists.koha-community.org/cgi-bin/mailman/listinfo/koha-devel</a><br class="gmail_msg">
website : <a href="http://www.koha-community.org/" rel="noreferrer" class="gmail_msg" target="_blank">http://www.koha-community.org/</a><br class="gmail_msg">
git : <a href="http://git.koha-community.org/" rel="noreferrer" class="gmail_msg" target="_blank">http://git.koha-community.org/</a><br class="gmail_msg">
bugs : <a href="http://bugs.koha-community.org/" rel="noreferrer" class="gmail_msg" target="_blank">http://bugs.koha-community.org/</a></blockquote></div></div><div dir="ltr">-- <br></div><div data-smartmail="gmail_signature"><div dir="ltr"><div style="color:rgb(117,117,117);font-family:"helvetica neue",helvetica,arial,sans-serif;font-size:12.8px">Tomás Cohen Arazi</div><div style="color:rgb(117,117,117);font-family:"helvetica neue",helvetica,arial,sans-serif;font-size:12.8px">Theke Solutions (<a href="http://theke.io/">https://theke.io</a>)<br>✆ +54 9351 3513384<br>GPG: B2F3C15F</div></div></div>