I use DRF-Spectacular to generate the OpenAPI specification for my DRF-based API. So far, I do not add examples but instead rely on SwaggerUI to show examples based on the type and regex patterns.
However, in same cases, I would like to add examples directly to the openapi.yml
file. I would like to define examples for individual Model
or Serializer
fields, similar to generating descriptions
based on the help_text
parameters.
Unfortunately, so far I've only found ways to defining complete examples for views and serializers based on OpenApiExample
with extend_schema
and extend_schema_serializer
, respectively.
This leads me to my question: Is it possible to define examples for individual Model
or Serializer
fields with DRF-Spectacular and, if yes, how?