Questions tagged [drf-yasg]

Automated generation of real Swagger/OpenAPI 2.0 schemas from Django Rest Framework code

189 questions
28
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', …
SungHo Kim
  • 291
  • 1
  • 3
  • 11
14
votes
5 answers

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…
JBWilkinson
  • 141
  • 1
  • 3
13
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…
rrauenza
  • 6,285
  • 4
  • 32
  • 57
12
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 =…
Belgi
  • 14,542
  • 22
  • 58
  • 68
12
votes
2 answers

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", …
lukik
  • 3,919
  • 6
  • 46
  • 89
11
votes
4 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…
R.yan
  • 2,214
  • 1
  • 16
  • 33
10
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…
10
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 =…
Praful Bagai
  • 16,684
  • 50
  • 136
  • 267
9
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…
frenzy
  • 1,632
  • 3
  • 16
  • 18
9
votes
2 answers

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, …
eugene
  • 39,839
  • 68
  • 255
  • 489
9
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…
8
votes
1 answer

drf-yasg swagger setup parameters IN_BODY is not worked

class Templates(APIView): parser_classes = (FormParser,) @swagger_auto_schema(manual_parameters=[ openapi.Parameter('title', in_=openapi.IN_FORM, description='作品标题', type=openapi.TYPE_STRING, required=True)] ) def post(self,…
Randon Peng
  • 105
  • 1
  • 5
8
votes
3 answers

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…
8
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' …
unknown
  • 252
  • 3
  • 12
  • 37
7
votes
1 answer

Django rest framework drf-yasg swagger multiple file upload error for ListField serializer

I am trying to make upload file input from swagger (with drf-yasg), but when I use MultiPartParser class it gives me the below error: drf_yasg.errors.SwaggerGenerationError: FileField is supported only in a formData Parameter or response Schema My…
I.Jokhadze
  • 456
  • 2
  • 8
  • 27
1
2 3
12 13