Automated generation of real Swagger/OpenAPI 2.0 schemas from Django Rest Framework code
Questions tagged [drf-yasg]
189 questions
4
votes
3 answers
drf_yasg documentation parameters not showing
I am using drf_yasg to self document my API which is built using the django-framework, but none of the parameters are displaying at all for any of the endpoints. The way I've done it is to pass the parameters within the http request body in JSON…

OptimusPrime
- 777
- 16
- 25
4
votes
1 answer
Swagger Django [No operations defined in spec]
I have been trying to integrate Swagger with Django Application and encounter this error:
No operations defined in spec!
My project structure is
App
views.py
urls.py
..
App2
settings.py
urls.py
..
I am using drf_yasg for…

Floura Angel
- 99
- 2
- 6
4
votes
1 answer
drf-yasg custom json body
How to customize drf-yasg schema in ClassBased django views?
I tried this part of code, but the generated swagger doesn't respect the change.
class CustomView(CreateAPIView):
permission_classes = (IsAuthenticated,)
serializer_class =…

Salehi
- 362
- 2
- 13
4
votes
2 answers
How can I disable/remove authorize button in swagger drf_yasg (maintain CSRF) - django
How to disable the Authorize button in drf_yasg ? (I still want CSRF to work)
UPDATE:
currently, I have the settings this way, because I would like to remove Django login and also maintain csrf. However, Authorize button still exist (How do I…

Bulbul Shivhare
- 41
- 1
- 4
4
votes
0 answers
Documenting a DRF GET endpoint with multiple responses using Swagger
I have a GET endpoint for a RESTful API I am creating using Django.
This endpoint reads three values from the URL's query string. A particular parameter in the query string has the potential to change the data (include extra fields and change the…

Guybrush
- 256
- 4
- 16
4
votes
1 answer
Add swagger description in comments
Can I customize swagger description by comment viewset?
I use drf-yasg.
My code:
class MetricViewSet(viewsets.ReadOnlyModelViewSet):
"""
retrieve:
Получить из справочника данные записи о метрике по *uuid*
list:
…

Vetos
- 295
- 2
- 10
4
votes
2 answers
"http method not bound to view" when documenting class-based view in drf_yasg
Previously, I documented my function-based views like this:
@swagger_auto_schema(
operation_id='ChangePassword',
methods=['POST'],
request_body=ChangePasswordSerializer,
responses={
'200': 'empty response body',
})
def…

2v0mjdrl
- 582
- 4
- 19
3
votes
0 answers
drf-yasg cover all responses to following implemented standard api response
I did implement the standard API response such as this article in my app. And I also implement drf-yasg for my API documentation. As we know the schema are using directly serializer to present the response. How I can cover all these below response…

binpy
- 3,994
- 3
- 17
- 54
3
votes
0 answers
How to change example format value of datefield in drf yasg (swagger)
Hello im using drf yasg library to implement swagger in my django based app. I have changed the date format in settings.py file to look like this:
REST_FRAMEWORK = {
"DATE_INPUT_FORMATS": ["%d-%m-%Y"],
}
Now when I try to test my endpoint in…

Beorn
- 417
- 1
- 5
- 13
3
votes
3 answers
base_url issues in drf_yasg swagger
I am running Django with Nginx in 8000 port. Here Nginx is exposed outside in 8000 port. But in Swagger UI the base_url is set as without port. So Swagger is trying to access endpoints without a port, then it gives a response as TypeError: Failed to…

CHIDAMBARANATHAN M
- 121
- 2
- 8
3
votes
1 answer
How to tag whole ViewSet in drf_yasg?
I have the following ViewSet:
class AuthorViewSet(viewsets.ModelViewSet):
queryset = Author.objects.all()
serializer_class = AuthorSerializer
permission_classes = [permissions.AllowAny]
# note that no methods are overridden
I want…

Lev
- 146
- 2
- 12
3
votes
1 answer
combine multiple swagger docs ( from different applications ) into one swagger dashboard [drf_yasg]
If I have 5 applications(django),with respective swagger docs, is it possible to combine all the swagger docs as one swagger docs.
I'm using django rest framework.

Nb2311
- 31
- 2
3
votes
1 answer
drf-yasg Customize SwaggerUIRenderer
I'd like to customize the style (font, colors, logo, etc) of drf_yasg generated docs.
I see that I can extend drf_yasg/swagger-ui.html with the blocks extra_head, extra_styles, extra_body, extra_scripts, and can even overwrite the other blocks if I…

Vishal
- 2,097
- 6
- 27
- 45
3
votes
2 answers
How to add own Parameters and Response values in the drf-yasg library for swagger documentation?
I use the drf-yasg library to generate project documentation for the developer front-ends. I can't figure out how to add my data to the fields Parameters and Responses
For example, this class
class VendorsCreateView(APIView):
"""
:param:
…

Jekson
- 2,892
- 8
- 44
- 79
3
votes
1 answer
How to add x-server & x-taggroups for ReDoc through drf-yasg
I am using drf-yasg for documentation,I am using redoc and it's working great. But I want to add x-server and x-taggroups. I would like to set custom tags for views, and add them to their own taggroups, but I cannot find anything in the docs about…

Anmola Singh
- 31
- 1