Questions tagged [drf-spectacular]

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

98 questions
0
votes
0 answers

How to send a cookie in DRF-Spectacular Authorization?

I have written a custom backend for JWT authentication in cookies. I'd like to test it using the DRF-Spectacular. To this end, I've written the following scheme: from drf_spectacular.extensions import OpenApiAuthenticationExtension from .backends…
Karol Borkowski
  • 532
  • 7
  • 19
0
votes
0 answers

patternProperties in @extend_schema_field

Is it possible to use "patternProperties" in @extend_schema_field decorator of drf-spectacular package? Something like that: class CustomSerializer(Serializer): values = SerializerMethodField() @extend_schema_field({ "type":…
Leonid
  • 121
  • 1
  • 11
0
votes
0 answers

Is it possible to keep the openapi file dynamic as the APIs change overtime?

Consider that I have a specific structure in the requestBody argument of the @extend_schema decorator. Over time if the API changes and the structure mentioned above has to change as well. How can we keep the OpenAPI file dynamic without updating…
0
votes
1 answer

django can't find url even though it is there

I have an issue where I try to go to my redirect page and get a NoReverseMatch when though the URL is there? Any idea how to fix this? I have checked that the "schema" url works and it correctly supplies the openapi schema, but the other page simply…
0
votes
1 answer

Authorization header is not sending when using Swagger documentation on drf-spectacular

I'm using drf-spectacular to document and test my endpoint. My code look like this: @extend_schema( parameters=[ OpenApiParameter(name='Authorization', description='Authorization token', required=True, type=str,…
0
votes
1 answer

Generate a custom response for an API endpoint in Django Rest Framework using drf-spectacular

I'm trying to generate the documentation for an function based view in DRF using the drf-spectacular library. The response that I'm trying to generate should look like this: As you can see "data" is a list. I tried to do the following: class…
0
votes
1 answer

Django Rest Framework - One serailizer for API and drf-spectacular

I have a serializer for DRF, and drf-spectacular. My serializer works that i expect but in GUI don't present currectly. So i need to have tho diffrents serializer one for schema and second for endpoint. But i wanna use one, how to fix this ? My…
LukaszK
  • 171
  • 10
0
votes
1 answer

Django Rest Framework - drf-spectacular add extra models to schemas

I used drf-spectacular and have two questions about this module. I wanna create custom Schemas and overwrite Schema in API endpoints. How to do this? I search a way to add custom models to Schemas but without connected this with endpoints. I see…
LukaszK
  • 171
  • 10
0
votes
1 answer

How to exclude drf router path from drf_spectacular SERVERS setting

I would like to verify some best practices when using drf_spectacular with a django project. I have an API in a django project where all the endpoints use the api/ prefix, i.e. in urls.py, I'm using. path('api/', include('myapp_api.urls')), The…
gmcc051
  • 390
  • 3
  • 17
0
votes
1 answer

Django rest spectacular - Customizing get_queryset()

I am trying to customize the redoc documents using DRF-Spectacular. For some reason, the extend_schema class is not updating the description, summary or tags on the document. How can I customize this? @extend_schema( summary="Get All…
Juanvulcano
  • 1,354
  • 3
  • 26
  • 44
0
votes
1 answer

drf-spectacular define request schema as JSON Array (like Serializer(many=True))

Is it possible to define "many" serializer schema in drf-spectacular? The request should take this data (JSONArray): MonthlyIncomeSerializer(many=True) Which is a list of objects/dictionaries: [ {'year':..., 'month':..., 'amount': ...}, …
Milano
  • 18,048
  • 37
  • 153
  • 353
0
votes
1 answer

drf-spectacular extend_schema_serializer can't do empty value example

I'm using the extend_schema_serializer decorator to document examples of json data that can be sent in a POST request. The problem is, one of the variations/examples requires no data, but the generated swagger doc insists on showing what looks like…
gmcc051
  • 390
  • 3
  • 17
0
votes
2 answers

drf-spectacular post method not working with form field

I am using Django Rest Framework. And for documentation I am using drf-spectacular. But the problem I am facing is that when I am trying to submit using form, I can not submit. But I can submit using JSON type normally. This Does not Work: This…
0
votes
2 answers

How to include Oauth2 auth urls in Swagger?

I use Django drf-spectacular OAuth Toolkit for an Oauth2 password flow. Unfortunately, Swagger doesn't recognize the auth URLs. This is my urls.py urlpatterns = [ # schema path("api/schema/", SpectacularAPIView.as_view(api_version='v1'),…
0
votes
1 answer

Problem to use @extend_schema over an @actoin in DRF

hi I have a @extend_schema of drf_spectacular library in my code I need to use it over my @action to customize the detail in OpenAPI, but I get errors like that Internal Server Error: /api/schema/ Traceback (most recent call last): File…
Nova
  • 413
  • 4
  • 11