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
A HTTP PATCH operation submits a subset of fields to the endpoint, so body: Json<SchemaA> isnt appropriate.
In Django REST Framework, there is builtin support for partial updates being performed by PATCH where mandatory-ness is dropped on the HTTP deserialisation, but other validation is maintained. [https://www.google.com/search?client=firefox-b-d&q=django+DRF+PATCH+updates] if you care to go down that rabbit hole to see how they do it.
It would be nice if there was some helper for actix-web that assisted with this, and it might be as simple as a derived-struct-generator which can be used like PatchedSchemaA = PatchableHelper(SchemaA, mandatory=["id_field"], patchable=["field3", "field7"]), so then body: Json<PatchedSchemaA> is usable for patch operations. e.g. https://crates.io/crates/optional_struct would be a good starting point . But is there a better solution? It looks quite new and has a lot of TODOs.
Perhaps adding an example of an actix-web patch endpoint with optional_struct (or similar) would be helpful?
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
A HTTP
PATCH
operation submits a subset of fields to the endpoint, sobody: Json<SchemaA>
isnt appropriate.In Django REST Framework, there is builtin support for partial updates being performed by
PATCH
where mandatory-ness is dropped on the HTTP deserialisation, but other validation is maintained. [https://www.google.com/search?client=firefox-b-d&q=django+DRF+PATCH+updates] if you care to go down that rabbit hole to see how they do it.It would be nice if there was some helper for actix-web that assisted with this, and it might be as simple as a derived-struct-generator which can be used like
PatchedSchemaA = PatchableHelper(SchemaA, mandatory=["id_field"], patchable=["field3", "field7"])
, so thenbody: Json<PatchedSchemaA>
is usable for patch operations. e.g. https://crates.io/crates/optional_struct would be a good starting point . But is there a better solution? It looks quite new and has a lot of TODOs.Perhaps adding an example of an actix-web patch endpoint with
optional_struct
(or similar) would be helpful?Beta Was this translation helpful? Give feedback.
All reactions