Open johnthagen opened 5 months ago
This code seems relevant to this issue
I was able to manually add partial=True
to work around this.
@extend_schema_view(
bulk_partial_update=extend_schema(
request=TSerializer(many=True, partial=True), responses=TSerializer(many=True)
),
)
So the only issue I have remaining is that for bulk partial updates, I need to have the required id
present, but all other fields marked optional. partial=True
solves the part of making all fields optional, but is there any clean way to also describe "even for this request, the id
field must exist"?
As an example of what the partial update data looks like:
[
{"id": 1, "name": "fred"},
{"id": 2, "age": 10}
]
I have an
@action
of the form:And a
ViewSet
of the form:I was hoping that because the
@action
was tagged asHTTPMethod.PATCH
thatdrf-spectacular
would automatically use thePatchedTRequest
form of the generatedT
for therequest
side of the API sincePATCH
is used in HTTP for partial updates.But when I looked at the generated OpenAPI spec, I found it looked like:
Specifically I was hoping that
requestBody
would usePatchedTRequest
.