Open HansAarneLiblik opened 1 month ago
Hi @HansAarneLiblik,
wouldn't an update endpoint where all fields are required be an PUT
operation instead of PATCH
? The whole point of PATCH
is to allow partial updates. For whole updates we have PUT
, right? I feel you struggle here because you try to shoehorn some functionality that is by definition not "restful".
Not sure if we should complicate the implementation, because it is certainly not as easy as MySerializerIn(force_impartial=True)
, because DRF does not allow extra unknown arguments, which was a route I tried to go before for another feature.
wouldn't an update endpoint where all fields are required be an
PUT
operation instead ofPATCH
?
I think there are use cases for required fields in PATCH
endpoints. For instance
old_name
+ new_name
. Or remove_items: [{id: 123}], add_items: [{id: 234}]
. Or maybe a full-blown JSON patch request.I think a fair argument could be that these aren't fully RESTful and should use POST
method (though there's no official document defining what "RESTful" truly means). But I have used PATCH
for such endpoints a couple of times and I don't think it's "too wrong".
Describe the bug I have some API endpoints, that need to be PATCH requests, but they are not conventional. They have at least 1 field, all of which are required
If I provide a serializer for this, drf-spectacular will make it a "PatchedSerializer", by making the serializer
partial
.To Reproduce
Generated Schema
Component Schema
Expected behavior I'd like a way to tell drf-spectacular to NOT make this serializer partial, as all the fields are required. Perhaps via
or a custom serializer field