Automated generation of real Swagger/OpenAPI 2.0 schemas from Django Rest Framework code
Questions tagged [drf-yasg]
97 questions
21
votes
1 answer
django rest framework - How to add post parameters to api document(drf_yasg)?
x_param = openapi.Parameter('x', in_=openapi.IN_FORM, description='srring',
type=openapi.TYPE_STRING)
y_param = openapi.Parameter('y', in_=openapi.IN_FORM, description='string',
…
![](../../users/profiles/8068446.webp)
SungHo Kim
- 261
- 2
- 6
10
votes
2 answers
How to dinstinctly document possible REST actions in ViewSet docstring?
The DRF docs mention this:
Note that when using viewsets the basic docstring is used for all
generated views. To provide descriptions for each view, such as for
the the list and retrieve views, use docstring sections as described
in Schemas…
![](../../users/profiles/2077386.webp)
rrauenza
- 5,161
- 4
- 27
- 45
8
votes
2 answers
Django, drf-yasg - how to add description to tags?
Swagger documentation says you can do that:
https://swagger.io/docs/specification/grouping-operations-with-tags/
But unfortunately drf-yasg not implementing this feature:
https://github.com/axnsan12/drf-yasg/issues/454
It is said, that I can add…
![](../../users/profiles/4474576.webp)
frenzy
- 1,231
- 1
- 13
- 18
8
votes
1 answer
Authenticating Swagger API docs (drf-yasg)
I've setup DRF-YASG but am unable to figure out how to configure it to show Views that require Authentication.
Below is the configuration.
schema_view = get_schema_view(
openapi.Info(
title="Swagger Doc",
…
![](../../users/profiles/1082673.webp)
lukik
- 3,213
- 4
- 36
- 72
7
votes
1 answer
Problem reusing serializers with django and drf-yasg
I am using django, django drf and drf-yasg to generate write my BE and generate documentation.
I have a model called User and a serializer for a user:
class UserSerializer(serializers.ModelSerializer):
class Meta:
model =…
![](../../users/profiles/729995.webp)
Belgi
- 13,002
- 21
- 50
- 63
7
votes
2 answers
How can I configure "HTTPS" schemes with the drf-yasg auto-generated swagger page?
I know in a traditional swagger YAML file, we can define the schemes with:
schemes:
- http
- https
//OR
schemes: [http, https]
However, how can I do the same thing with auto-generated swagger page with the drf-yasg library?
Now, the generated…
![](../../users/profiles/8490848.webp)
R.yan
- 1,694
- 7
- 29
7
votes
1 answer
DRF YASG Customizing
I'm trying to customize my api documentation buuild with yasg.
First off, I would like to determine the naming of my own sections, and what endpoints should be included in this section. It seems that the naming of sections is based on the first…
![](../../users/profiles/8412761.webp)
Joseph Groot Kormelink
- 229
- 3
- 10
6
votes
1 answer
drf-spectacular is using the wrong AutoSchema to generate Swagger
Previously I was using drf-yasg but want to update to use OpenAPI 3. I am trying to switch over to drf-spectacular. Following the instruction, I ran pip install drf-spectacular, I've removed all references to the drf-yasg package, and updated…
![](../../users/profiles/9801204.webp)
JBWilkinson
- 61
- 1
6
votes
1 answer
drf-yasg provides wrong paths to URIs
In my application I need to have multiple Swagger pages with grouped endpoints for multiple clients.
One of my clients (paths) supplies mobile app API, another supplies web client API. URL patterns are kept in 2 different urls.py accordingly.
I'm…
![](../../users/profiles/4726424.webp)
Stan Redoute
- 1,733
- 2
- 16
- 44
6
votes
1 answer
What do these arguments mean in swagger_auto_schema (Django)?
The project uses a swagger.
There is the following code.
@swagger_auto_schema(
manual_parameters=[
Parameter('download', IN_QUERY,
'Set `Content-Disposition=attachment` to make browser to download file'
…
![](../../users/profiles/12884304.webp)
unknown
- 63
- 1
- 5
- 26
6
votes
1 answer
drf-yasg document input and output serializer for GET request
I'd like to document input schemas and output schemas for GET request with drf-yasg.
It doesn't seem to be easy.
@swagger_auto_schema(
manual_parameters=[
openapi.Parameter('cart_id', in_=openapi.IN_QUERY,
…
![](../../users/profiles/433570.webp)
eugene
- 33,301
- 47
- 188
- 382
6
votes
1 answer
DRF - `write_only=True` displays in response schema
I'm using drf-yasg to document my APIs. However, I'm running into a problem
I've a serializer in which one of the fields is set to write_only=True.
class XYZSerializer(serializers.ModelSerializer):
status =…
![](../../users/profiles/1162512.webp)
PythonEnthusiast
- 14,299
- 33
- 103
- 218
5
votes
1 answer
Getting "AssertionError: duplicate Parameters found" when I hit /swagger url
I am implementing swagger using drf-yasg for django rest framework APIs in my project.
I follow the quick start section of drf-yasg. When I hit /swagger gets AssertionError: duplicate Parameters found. Below is my code and traceback.
urls.py
from…
![](../../users/profiles/6144732.webp)
Navjot Gwal
- 61
- 5
5
votes
2 answers
How change Schemes from HTTP to HTTPS in drf_yasg?
I'm using drf_yasg for swagger documentation. When I publish my DRF app behind AWS Application Load Balancer and set listener to listen on 443 HTTPS and redirect to my EC2 on which DRF is running, swagger UI is trying to send a request to endpoint…
![](../../users/profiles/8513898.webp)
Artur Siepietowski
- 518
- 4
- 13
5
votes
1 answer
Django 2.x drf-yasg how to create API in a custom method (like in swagger)
I am migrating my Django 1.11.7 to 2.x. One of the problems is django-rest-swagger, it is now deprecated. And drf-yasg should now be the way for the API documentation and creation. I need to do it in a similar way of creating custom api as so it…
![](../../users/profiles/1008933.webp)
Axil
- 2,835
- 5
- 43
- 97