Patron PATCH route is not yet implemented. PUT route is not exactly overwriting all data but there are some parameters which are required. PATCH route should accept updates from one to n fields.
Created attachment 91426 [details] [review] Bug 23285: Add patrons PATCH route Implementation for patrons PATCH route. Test plan - Apply this patch - Run prove t/db_dependent/api/v1/patrons.t - Create user with borrowers permissions - Authenticate with the user created above and get a CGISESSION id. - Use the CGISESSION to patch patrons via the API - PATCH /patrons/{patron_id} with some parameters in the body Sponsored-by: Koha-Suomi Oy
Please make this depend on #23843 so it doesn't conflict with it if it is pushed soon
Be careful with the "In Discussion" - maybe better to use FQA or back to Assigned?
Hmm.. At a quick glance this doesn't feel right.. somehow I feel like PATCH operations should utilise something like json-patch and send a list of change operations rather than just a partial copy of a whole object.
We do have "Update patron" with PUT in the API documentation - does this cover the use case? https://api.koha-community.org/#tag/patrons/operation/updatePatron
(In reply to Katrin Fischer from comment #5) > We do have "Update patron" with PUT in the API documentation - does this > cover the use case? > https://api.koha-community.org/#tag/patrons/operation/updatePatron This endpoint is mentioned on this documentation. https://wiki.koha-community.org/wiki/Patrons_endpoint_RFC The difference between PUT and PATCH is that PUT updates the entire resource and PATCH updates only partial of the data without modifying the entire data. At moment if you want to update one value, you need to update them all. I guess Martin's comment was how is the response showed, correct me if I'm wrong.
(In reply to Johanna Räisä from comment #6) > (In reply to Katrin Fischer from comment #5) > > We do have "Update patron" with PUT in the API documentation - does this > > cover the use case? > > https://api.koha-community.org/#tag/patrons/operation/updatePatron > > This endpoint is mentioned on this documentation. > https://wiki.koha-community.org/wiki/Patrons_endpoint_RFC > > The difference between PUT and PATCH is that PUT updates the entire resource > and PATCH updates only partial of the data without modifying the entire data. > > At moment if you want to update one value, you need to update them all. > > I guess Martin's comment was how is the response showed, correct me if I'm > wrong. Hi Johanna, I believe we do also support partial with PUT even if it might not be totally clear from documentation.
I've tested and I cant do partial update with PUT. I get "missing property" message. I think since for both post and put we define for body : schema: $ref: "../swagger.yaml#/definitions/patron" And in /api/v1/swagger/definitions/patron.yaml we have: required: - surname - library_id - category_id
(In reply to Fridolin Somers from comment #8) > I've tested and I cant do partial update with PUT. > I get "missing property" message. > > I think since for both post and put we define for body : > schema: > $ref: "../swagger.yaml#/definitions/patron" > > And in /api/v1/swagger/definitions/patron.yaml we have: > required: > - surname > - library_id > - category_id It works, but you need to include those three always right now. (I just recently looked into that and we had discussed it on IRC)
I've been discussing this in mailing list koha-devel (REST API : PUT for partial update). So we do need a PATCH route. It would be very useful to update for example the expiration date. Is there a way to set required fields outside api/v1/swagger/definitions/patron.yaml so that is can be used in both PATCH,PUT and POST routes ?
(In reply to Fridolin Somers from comment #10) > I've been discussing this in mailing list koha-devel (REST API : PUT for > partial update). > > So we do need a PATCH route. > It would be very useful to update for example the expiration date. > > Is there a way to set required fields outside > api/v1/swagger/definitions/patron.yaml so that is can be used in both > PATCH,PUT and POST routes ? The way to do it, implies loosing reusability of the object definitions, which I don't think is a big deal anyway. We would just need to be observant on any attribute changes so they are applied both in patron.yaml and (say) patron_patch.yaml.