Questions tagged [drf-spectacular]

Sane and flexible OpenAPI 3.0 schema generation for Django REST framework.

98 questions
2
votes
0 answers

could not derive type of path parameter "id" because it is untyped and obtaining queryset from the viewset failed

could not derive type of path parameter "id" because it is untyped and obtaining queryset from the viewset failed. Consider adding a type to the path (e.g. int:id) or annotating the parameter type with @extend_schema. Defaulting to "string". This…
2
votes
0 answers

drf-spectacular request body schema field description

I'm struggling to find a way to add a field description to my request body fields, they are picked up by the serializer definion just fine but I would like to add a description line to better explain what the field should be. I can easily do this…
Yowsa
  • 21
  • 1
2
votes
0 answers

How to add reference Parameters in extend_schema decorator in drf-spectacular

I'm using drf-spectacular to generate the swagger/redoc API documentation. I am facing issue in customising the schemas generated. I am trying to generate reference parameter using @extend_schema decorators in drf_spectacular but did'nt get the…
2
votes
1 answer

Field with default value appears as optional in schema

Describe the bug My code has the following model with a boolean field, published, with a default value of false class PublishableModel(models.Model): """Fields used to determine if and when something is published.""" published =…
jester66
  • 242
  • 2
  • 10
2
votes
1 answer

drf spectacular generating wrong example per response

Having 2 response schemas for response, wanted to add examples to document error codes. Wanted error code response example: { "api_status_code": "DATE_PARSE_ERROR", "extra": { "details": "asdf" } } but in swagger-ui I'm…
jnowak
  • 641
  • 1
  • 6
  • 13
2
votes
1 answer

drf-spectacular does not show parameters in swagger-ui if they are optional

I am trying to implement some API by using GenericViewSet. I have also some FilterSet class with some custom optional fields. My issue is the generation of these custom fields in swagger-ui endpoint documentation. Generated schema just does not…
2
votes
1 answer

How to add global header parameter to all url paths in drf_spectacular?

I'm using drf_spectacular to be able to use swagger and it's working fine. I define the required parameters for my API views (whether in the path or in the header) like this: @extend_schema( OpenApiParameter( name='accept-language', …
2
votes
0 answers

Generate openapi 3 shared request and response components with drf-spectacular

Is there a way to generate openapi shared response and request objects using drf-spectacular? In the resulting JSON, I would expect to see "$ref": "#/components/responses/ErrorResponse", not "$ref": "#/components/schemas/ErrorResponse" I've tried…
Ovidiu
  • 131
  • 1
  • 11
2
votes
2 answers

Is there a way to change the autogenerated shema name of a serializer in drf-spectacular

I got many serializers named 'InputSerializer' and 'OutputSerializer' which translates to 'Input' and 'Output' schema name in drf-spectacular. This ends up referring the api endpoints to the same schema. Is there a way to override the autogenerated…
2
votes
1 answer

drf-yasg/drf-spectacular - description for filter parameters

EDIT: This question was originally posted when using yasg but I switched to spectacular so both solutions are ok. I'm curious if there is a way to tell the yasg or spectacular to add description to django-filter parameters. I want to tell developers…
Milano
  • 18,048
  • 37
  • 153
  • 353
2
votes
1 answer

Django REST drf-spectacular wrong detection of nested fields

if there are more than one fields with relations to other models and depth>=1 is specified on the serializer Meta class, in the example generated for the corresponding url, all of the relation fields have the same object as their value, for…
2
votes
1 answer

How do I include 400 validation errors in drf-spectacular?

I want to view validation details in 400 response as they can be reutrned by the serializer. The serializer can return errors depending on a missing field or invalid value and I want the documentation to indicate which kind of errors can appear with…
Anjayluh
  • 1,647
  • 1
  • 13
  • 22
2
votes
1 answer

Is there an alternative to using a serializer for drf-spectacular's extend_schema request param?

I'm using drf-spectacular to generate swagger/redoc API documentation. One of the most useful features is the ability to test requests via the generated swagger html page, but I'd like to enforce the application/x-www-form-urlencoded content-type so…
gmcc051
  • 390
  • 3
  • 17
2
votes
1 answer

How to send custom JSON headers with requests in drf_spectacular (django)?

Can I create an custom description of JSON headers in drf_spectacular without using serializers class in @extend_schema decorator?
1
vote
0 answers

Manually decorating function with extend_schema results in RecursionError

I have a HistoricalModelViewSet class which is used in all other view sets (class StuffViewSet(HistoricalModelViewSet)), it adds couple of /history endpoints (DRF thing,…
himmip
  • 1,360
  • 2
  • 12
  • 24