You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Consider a simple struct with two nullable string fields:
type Foo struct {
A *string `json:"a"`
B *string `json:"b"`
}
It is evidently impossible to set these fields to nil via a PATCH with application/merge-patch+json content type. For instance, the following request will throw a 422 with a message "expected required property a to be present".
This seems like a bug in merge patch computation: the PUT body in the autogenerated GET/PUT sequence omits the a field altogether instead of setting a: null as expected.
The only way to set a to nil appears to be via a PUT of the full struct or via a json-patch (not merge-patch):
Consider a simple struct with two nullable string fields:
It is evidently impossible to set these fields to
nil
via aPATCH
withapplication/merge-patch+json
content type. For instance, the following request will throw a 422 with a message "expected required property a to be present".This seems like a bug in merge patch computation: the
PUT
body in the autogeneratedGET
/PUT
sequence omits thea
field altogether instead of settinga: null
as expected.The only way to set
a
tonil
appears to be via aPUT
of the full struct or via ajson-patch
(notmerge-patch
):This came as an unfortunate surprise as our front-end client started making use of PATCH requests.
The text was updated successfully, but these errors were encountered: