Sane and flexible OpenAPI 3.0 schema generation for Django REST framework.
Questions tagged [drf-spectacular]
98 questions
1
vote
0 answers
drf-spectacular swagger authentication
I'm digging google for 3 hours right now, and can't find solution for my problem. I moved in my project from drf-yasg to drf-spectacular because openapi +3.0 isn't supported in yasg. I want to have an authentication to swagger page. I had a solution…

Lukas
- 35
- 1
- 3
1
vote
0 answers
How to document a tuple with different data types using drf-spectacular?
I'm using drf-spectacular to generate a Swagger documentation.
I have a viewset that returns a dict (it doesn't go through a drf serializer as it's all native objects).
The dict looks like this:
data = {
"lines": List[str],
…

Benjamin_Mourgues
- 339
- 1
- 11
1
vote
1 answer
drf-spectacular error - Function Based Views - unable to guess serializer
I'm getting the following error when trying to generate the schema:
" Error [get_token]: unable to guess serializer. This is graceful fallback handling for APIViews. Consider using GenericAPIView as view base class, if view is under your control.…

RFang
- 137
- 1
- 8
1
vote
0 answers
Mixin using @extend_schema (drf_spectacular) using instance serializer
I want to set the responses for @extend_schema dynamically.
The Mixin is inherited by different Subclasses, their response can vary depending on their Serializer. Therefore I would like to have the responses be set dynamically. Is that…

Andreas
- 8,694
- 3
- 14
- 38
1
vote
1 answer
remove `format: uuid` from drf-spectacular generated openapi schema
Google Apigee does not currently support format: uuid types. Is there any way to suppress format: uuid from AlbumSerializer when generating the openapi schema using drf-spectacular?
@extend_schema(
request=AlbumCreationSerializer,
…

Ajax
- 1,418
- 2
- 17
- 38
1
vote
0 answers
How to include the JSON Schema definition of a JSONField inside the OpenAPI schema generated by drf-spectacular?
By default, when using drf-spectacular to generate the OpenAPI schema, the JSONField will be typed as object or array. However, I have a JSON Field which is validated against a JSON Schema and I'd like this JSON Schema to be included on the OpenAPI…

CurlyError
- 305
- 2
- 15
1
vote
1 answer
Adding several schema encoding URLs in Django REST framework swagger-ui.html template
I have the swagger-ui.html file in a Django (v4.1.2) app as follow (taken from the Django REST framework doc):
Swagger

swiss_knight
- 5,787
- 8
- 50
- 92
1
vote
0 answers
Is there any way to overwrite the default operation id , tag, name ,description of generated drf api schema?
Is there any way to overwrite the default operationid,name,tag,type,summary, description of generated drf api schema?
When use drf-yasg or drf-spectacular,
is there any way to overwrite the default description shown in the sample picture
or does…

Shilpi Yadav
- 11
- 2
1
vote
2 answers
want to return percentage in Django Rest Framework
I wanted to return the percentage of every poll options_data in response.
I'm Expecting output Like in below.
{
"response": true,
"return_code": "remove_vote_success",
"result": {
"id": 9,
"user_id": 2,
…

MdHassan413
- 63
- 9
1
vote
1 answer
Is it possible to add response examples to non-200 responses
Is it possible to add examples: for non-200 responses, such as 400?
I noticed that using using the same serializer for both 200 and 400 generates the schema correctly, but does not include the example in the 400 response.
@extend_schema_serializer(
…

Andrew
- 8,322
- 2
- 47
- 70
1
vote
1 answer
drf-spectacular shows APIs registered with Django's APIView multiple times
This is my APIView
class NewUserView(APIView):
permission_classes = [permissions.IsAuthenticated, ]
renderer_classes = [CustomRenderer]
serializer_class = NewUserSerializer
@extend_schema(
…

Abhinav Dev
- 153
- 8
1
vote
1 answer
ModuleNotFoundError: No module named 'drf_spectacular.views'
urls.py
from drf_spectacular.views import SpectacularAPIView, SpectacularRedocView,
SpectacularSwaggerView
from django.contrib import admin
from django.urls import path, include
urlpatterns = [
path('admin/', admin.site.urls),
…

KRISHNANDU RANJN ROY
- 39
- 1
- 7
1
vote
1 answer
Django drf-spectacular with FirebaseBackend auth
To give as much context as possible; I have two problems while using drf-spectacular to build my API documentation;
With my default configuration, I cannot even load the documentation's page because I have a custom auth backend (using…

Manuhito
- 45
- 8
1
vote
1 answer
Django 4 with drf_spectacular Swagger does not execute POST
I have the following classes using the django-restframework and drf-spectacular.
I can execute POST when I am logged in and through the drf default routes, but not using the swagger-ui routes.
I can go to this url:…

Soerendip
- 7,684
- 15
- 61
- 128
1
vote
1 answer
Show request duration in drf-spectacular (Swagger)
I have a Django/DRF project with drf-spectacular (Swagger) integration and wondering how can I add a request duration as shown on the image below. Is there any way to achive elapsed time section? Thanks in advance.

voilalex
- 2,041
- 2
- 13
- 18