Re: [Koha-devel] REST API : PUT for partial update

2024-03-21 Thread Tomas Cohen Arazi via Koha-devel
Setting a null value willl set it to null, if nullable. Yes!

El jue, 21 mar 2024 a las 10:07, Fridolin SOMERS via Koha-devel (<
koha-devel@lists.koha-community.org>) escribió:

>
>
> Le 21/03/2024 à 11:18, Fridolin SOMERS via Koha-devel a écrit :
> > OK
> >
> > But currently this means in PUT you need to add in body the required
> > fields (even when unchanged) and the fields you want to change.
> > Missing fields are kept unchanged right ?
> > So there is no way to blank a field ?
> Looks like we can use null (unquoted of course) :
> For example in PUT /libraries/ :
> --data-raw '{ "name": "toto", "library_id": "ID", "address1": null }'
>
> It blanks the address1
>
> Anyone confirm ?
>
> >
> > The need was updating patron expiration date.
> > So maybe better create a dedicated route with only PUT.
> > Like the one for privacy :
> > /public/patrons/{patron_id}/guarantors/can_see_charges
> >
> > We should add some text to wiki :
> > https://wiki.koha-community.org/wiki/Koha_REST_API_Users_Guide
> >
> >
> > Le 20/03/2024 à 16:45, Tomas Cohen Arazi a écrit :
> >> When we decided to implement the RESTful API, we agreed PUT is for
> >> 'replacing' resources, and PATCH for updating selected pieces of them.
> >>
> >> I personally never managed to wrap my mind around PATCH and how to
> >> validate what tiny bit is allowed to be patched or not. As OpenAPIv2
> >> is not that flexible.
> >>
> >> But I'm sure Jonathan has implemented PATCH on the ERM, and those
> >> controllers look exactly the same as those for PUT.
> >>
> >> That said, I think we could just implement PATCH on the spec, pointing
> >> to the same controllers (for now) on an as-needed basis.
> >>
> >> Beware validation of combined parameters, etc.
> >>
> >> Good luck!
> >>
> >> El mié, 20 mar 2024 a las 11:03, Fridolin SOMERS via Koha-devel
> >> ( >> >) escribió:
> >>
> >> Hi,
> >>
> >> I've tried to use API for a PUT on patron.
> >>
> >> Looks like I can't do a partial update, I get error on mandatory
> >> datas
> >> like if it where a POST.
> >>
> >> I found this discussion :
> >> https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=23285#c8
> >>  >
> >>
> >> Is this a bug ?
> >>
> >> Best regards,
> >>
> >> -- Fridolin SOMERS  >> >
> >> Software and system maintainer 濾
> >> BibLibre, France
> >> ___
> >> Koha-devel mailing list
> >> Koha-devel@lists.koha-community.org
> >> 
> >>
> https://lists.koha-community.org/cgi-bin/mailman/listinfo/koha-devel
> >>
> >> 
> >> website : https://www.koha-community.org/
> >> 
> >> git : https://git.koha-community.org/
> >> 
> >> bugs : https://bugs.koha-community.org/
> >> 
> >>
> >>
> >>
> >> --
> >> Tomás Cohen Arazi
> >> Theke Solutions (https://theke.io )
> >> ✆ +54 9351 3513384
> >> GPG: B2F3C15F
> >
>
> --
> Fridolin SOMERS 
> Software and system maintainer 濾
> BibLibre, France
> ___
> Koha-devel mailing list
> Koha-devel@lists.koha-community.org
> https://lists.koha-community.org/cgi-bin/mailman/listinfo/koha-devel
> website : https://www.koha-community.org/
> git : https://git.koha-community.org/
> bugs : https://bugs.koha-community.org/
>


-- 
Tomás Cohen Arazi
Theke Solutions (https://theke.io)
✆ +54 9351 3513384
GPG: B2F3C15F
___
Koha-devel mailing list
Koha-devel@lists.koha-community.org
https://lists.koha-community.org/cgi-bin/mailman/listinfo/koha-devel
website : https://www.koha-community.org/
git : https://git.koha-community.org/
bugs : https://bugs.koha-community.org/


Re: [Koha-devel] REST API : PUT for partial update

2024-03-21 Thread Fridolin SOMERS via Koha-devel



Le 21/03/2024 à 11:18, Fridolin SOMERS via Koha-devel a écrit :

OK

But currently this means in PUT you need to add in body the required 
fields (even when unchanged) and the fields you want to change.

Missing fields are kept unchanged right ?
So there is no way to blank a field ?

Looks like we can use null (unquoted of course) :
For example in PUT /libraries/ :
--data-raw '{ "name": "toto", "library_id": "ID", "address1": null }'

It blanks the address1

Anyone confirm ?



The need was updating patron expiration date.
So maybe better create a dedicated route with only PUT.
Like the one for privacy :
/public/patrons/{patron_id}/guarantors/can_see_charges

We should add some text to wiki :
https://wiki.koha-community.org/wiki/Koha_REST_API_Users_Guide


Le 20/03/2024 à 16:45, Tomas Cohen Arazi a écrit :
When we decided to implement the RESTful API, we agreed PUT is for 
'replacing' resources, and PATCH for updating selected pieces of them.


I personally never managed to wrap my mind around PATCH and how to 
validate what tiny bit is allowed to be patched or not. As OpenAPIv2 
is not that flexible.


But I'm sure Jonathan has implemented PATCH on the ERM, and those 
controllers look exactly the same as those for PUT.


That said, I think we could just implement PATCH on the spec, pointing 
to the same controllers (for now) on an as-needed basis.


Beware validation of combined parameters, etc.

Good luck!

El mié, 20 mar 2024 a las 11:03, Fridolin SOMERS via Koha-devel 
(>) escribió:


    Hi,

    I've tried to use API for a PUT on patron.

    Looks like I can't do a partial update, I get error on mandatory 
datas

    like if it where a POST.

    I found this discussion :
    https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=23285#c8
    

    Is this a bug ?

    Best regards,

    --     Fridolin SOMERS mailto:fridolin.som...@biblibre.com>>
    Software and system maintainer 濾
    BibLibre, France
    ___
    Koha-devel mailing list
    Koha-devel@lists.koha-community.org
    
    https://lists.koha-community.org/cgi-bin/mailman/listinfo/koha-devel



    website : https://www.koha-community.org/
    
    git : https://git.koha-community.org/ 


    bugs : https://bugs.koha-community.org/
    



--
Tomás Cohen Arazi
Theke Solutions (https://theke.io )
✆ +54 9351 3513384
GPG: B2F3C15F




--
Fridolin SOMERS 
Software and system maintainer 濾
BibLibre, France
___
Koha-devel mailing list
Koha-devel@lists.koha-community.org
https://lists.koha-community.org/cgi-bin/mailman/listinfo/koha-devel
website : https://www.koha-community.org/
git : https://git.koha-community.org/
bugs : https://bugs.koha-community.org/


Re: [Koha-devel] REST API : PUT for partial update

2024-03-21 Thread Fridolin SOMERS via Koha-devel

OK

But currently this means in PUT you need to add in body the required 
fields (even when unchanged) and the fields you want to change.

Missing fields are kept unchanged right ?
So there is no way to blank a field ?

The need was updating patron expiration date.
So maybe better create a dedicated route with only PUT.
Like the one for privacy :
/public/patrons/{patron_id}/guarantors/can_see_charges

We should add some text to wiki :
https://wiki.koha-community.org/wiki/Koha_REST_API_Users_Guide


Le 20/03/2024 à 16:45, Tomas Cohen Arazi a écrit :
When we decided to implement the RESTful API, we agreed PUT is for 
'replacing' resources, and PATCH for updating selected pieces of them.


I personally never managed to wrap my mind around PATCH and how to 
validate what tiny bit is allowed to be patched or not. As OpenAPIv2 is 
not that flexible.


But I'm sure Jonathan has implemented PATCH on the ERM, and those 
controllers look exactly the same as those for PUT.


That said, I think we could just implement PATCH on the spec, pointing 
to the same controllers (for now) on an as-needed basis.


Beware validation of combined parameters, etc.

Good luck!

El mié, 20 mar 2024 a las 11:03, Fridolin SOMERS via Koha-devel 
(>) escribió:


Hi,

I've tried to use API for a PUT on patron.

Looks like I can't do a partial update, I get error on mandatory datas
like if it where a POST.

I found this discussion :
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=23285#c8


Is this a bug ?

Best regards,

-- 
Fridolin SOMERS 
>
Software and system maintainer 濾
BibLibre, France
___
Koha-devel mailing list
Koha-devel@lists.koha-community.org

https://lists.koha-community.org/cgi-bin/mailman/listinfo/koha-devel

website : https://www.koha-community.org/

git : https://git.koha-community.org/ 
bugs : https://bugs.koha-community.org/




--
Tomás Cohen Arazi
Theke Solutions (https://theke.io )
✆ +54 9351 3513384
GPG: B2F3C15F


--
Fridolin SOMERS 
Software and system maintainer 濾
BibLibre, France
___
Koha-devel mailing list
Koha-devel@lists.koha-community.org
https://lists.koha-community.org/cgi-bin/mailman/listinfo/koha-devel
website : https://www.koha-community.org/
git : https://git.koha-community.org/
bugs : https://bugs.koha-community.org/


Re: [Koha-devel] REST API : PUT for partial update

2024-03-20 Thread Tomas Cohen Arazi via Koha-devel
When we decided to implement the RESTful API, we agreed PUT is for
'replacing' resources, and PATCH for updating selected pieces of them.

I personally never managed to wrap my mind around PATCH and how to validate
what tiny bit is allowed to be patched or not. As OpenAPIv2 is not that
flexible.

But I'm sure Jonathan has implemented PATCH on the ERM, and those
controllers look exactly the same as those for PUT.

That said, I think we could just implement PATCH on the spec, pointing to
the same controllers (for now) on an as-needed basis.

Beware validation of combined parameters, etc.

Good luck!

El mié, 20 mar 2024 a las 11:03, Fridolin SOMERS via Koha-devel (<
koha-devel@lists.koha-community.org>) escribió:

> Hi,
>
> I've tried to use API for a PUT on patron.
>
> Looks like I can't do a partial update, I get error on mandatory datas
> like if it where a POST.
>
> I found this discussion :
> https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=23285#c8
>
> Is this a bug ?
>
> Best regards,
>
> --
> Fridolin SOMERS 
> Software and system maintainer 濾
> BibLibre, France
> ___
> Koha-devel mailing list
> Koha-devel@lists.koha-community.org
> https://lists.koha-community.org/cgi-bin/mailman/listinfo/koha-devel
> website : https://www.koha-community.org/
> git : https://git.koha-community.org/
> bugs : https://bugs.koha-community.org/
>


-- 
Tomás Cohen Arazi
Theke Solutions (https://theke.io)
✆ +54 9351 3513384
GPG: B2F3C15F
___
Koha-devel mailing list
Koha-devel@lists.koha-community.org
https://lists.koha-community.org/cgi-bin/mailman/listinfo/koha-devel
website : https://www.koha-community.org/
git : https://git.koha-community.org/
bugs : https://bugs.koha-community.org/