Sane and flexible OpenAPI 3.0 schema generation for Django REST framework.
Questions tagged [drf-spectacular]
98 questions
0
votes
0 answers
Migrating 'openapi.Schema()' from drf-yasg to drf-spectacular
I'm migrating from drf-yasg to drf-spectacular, using the From drf-yasg to OpenAPI 3, and I've done most of my docs, but I have some problems triying to replace my old openapi.Schema().
By the docs Schema is not required and can be eliminated. Use a…

Poor-Man
- 1
- 3
0
votes
0 answers
How to define two docs for two different URL patterns in Django rest?
ADMIN_API_SPECTACULAR_SETTINGS = {
'TITLE': 'Gravity API Admin',
'DESCRIPTION': 'Your admin API description',
'VERSION': '1.0.0',
'SCHEMA_PATH_PREFIX': '/admin-api/v1/',
"POSTPROCESSING_HOOKS": [
…

Bibek
- 21
- 5
0
votes
0 answers
drf-spectacular with custom permission on endpoint
I've got problem with drf-spectacular library. I prepared decorators for my viewset, but I can't see endpoints in this viewset on my schema. I figured out that my custom permission to these endpoints blocks it (When I set my permissions to AllowAny…

Ronczo
- 1
0
votes
1 answer
How do I properly configure `drf-spectacular` in my Django projects
I simply installed and configured drf-spectacular in my Django project, but when I visit the url http://127.0.0.1:8000/api/v1/schema/, Django throws this error.
TypeError at /api/v1/schema/ Field 'id' expected a number but got…

Gilles Ashley
- 39
- 1
- 9
0
votes
0 answers
Django serializer field with more than one type
I need to create a field that is either a CharField or a list of char fields.
Pseudo code:
class MySerializer(Serializer):
my_field = CharField() | ListField(child=CharField())
...
I also need it to be properly recognised by DRF Spectacular…

Slav
- 147
- 2
- 13
0
votes
1 answer
How to show required request body using django rest framework + drf_spectacular + swagger
I started using drf_spectacular and swagger recently, I have a an API endpoint that expects request body with field in it, however I can't seem to understand how to reveal this in the UI.
my view:
@extend_schema(
responses={200:…

Ron Amir
- 23
- 4
0
votes
1 answer
def-spectacular not generate schema urls for django-oauth-toolkit urls
I'm trying to generate Open API schema.
settings.py:
SPECTACULAR_SETTINGS = {
'TITLE': 'TMC Authentication API',
'DESCRIPTION': 'Description',
'VERSION': '1.0.0',
'SERVE_INCLUDE_SCHEMA': False,
'SWAGGER_UI_DIST': 'SIDECAR',
…

Alberto Sanmartin Martinez
- 970
- 13
- 37
0
votes
0 answers
How to extend DRF generic views to generate Open API schema?
I'm trying to generate Open API schema with Django Rest Framework and DRF Spectacular,
The option 2 works well and return component schema well but but i would like to use option 1 to customize parent class of child views.
Option 1:
urls.py:
path(
…

Alberto Sanmartin Martinez
- 970
- 13
- 37
0
votes
1 answer
How can I disable/remove authorize button in swagger drf_spectacular - django
I'm working on DRF-spectacular.
My question is how to disable Authorize Button in DRF-spectacular.
Are there any settings?
enter image description here

Saurabh
- 3
- 2
0
votes
0 answers
Union of non-model serializers in Django Rest Framework
Through serializers, I'm trying to describe that a field could be serialized as one of N options (similar to typing.Union). The goal of this is to use DRF Spectacular to generate Union Types. For example:
From the following serializers
class…

Josh
- 1
- 1
0
votes
2 answers
drf-spectacular: Automatic rendering of schema fields
Is there a setting that will automatically display field data?
Used:
Django==3.0.14
drf-spectacular==0.24.2
drf-spectacular-sidecar==2022.12.1
drf-spectacular settings
SPECTACULAR_SETTINGS = {
'SERVE_INCLUDE_SCHEMA': False,
# Permission
…

Gilions
- 1
0
votes
0 answers
How to customize drf-yasg / drf-spectacular open api schema for aws gateway integration?
I have a requirement to integrate all the api urls in my django service with AWS gateway.
I tried importing the open api spec(swagger json) generated by drf-yasg/drf-spectacular into aws. But this seems create only the resources and methods for the…

Ravish Mallya
- 47
- 5
0
votes
0 answers
drf spectacular add summary to view
i have method in view
@action(detail=True, methods=['post'])
def request_feedback(self, request, pk=None):
""" Request for exceptional holiness
from the driver on some issue and """
...
return Response
now I want…

good bye
- 1
0
votes
0 answers
Get component schema for a specific endpoint with drf spectacular
I want to use drf spectacular to get the component schema of a specific endpoint.
For example, if I have the endpoint api\articles that supports POST with two CharFields field1 and field2. I then want another endpoint such as…

shimeji42
- 313
- 1
- 11
0
votes
1 answer
How to show the operation_id in drf_spectacular?
Is there a way to show the operation_id in drf_spectacular like it is shown in drf_yasg? The docs don't show anything regarding this setting. The operation_id is used in our code generators, so it is very practical to view it in the overview.

creyD
- 1,972
- 3
- 26
- 55