1👍
The OpenApiExample
object contains a status_code
property that is by default set to ['200', '201']
.
Try something like this:
@extend_schema_serializer(
component_name="CostResponse",
examples=[
OpenApiExample(
status_codes=['200', '400', '406'],
name="A Great Example!",
value={"field": "Example Value"}
)
]
)
class CostResponseSerializer(Serializer):
field = CharField(help_text="Thing")
That way you can specify examples per status codes.
Source:stackexchange.com