Questions tagged [drf-yasg]

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

189 questions
0
votes
0 answers

Swagger - add manual parameters?

Very new to swagger class VerifyEmailAPI(generics.GenericAPIView): """ Verify Email of a registered user """ token_param_config = openapi.Schema(type=openapi.TYPE_OBJECT, properties={ 'token':…
Sid
  • 3,749
  • 7
  • 29
  • 62
0
votes
0 answers

CSS files not loading in drf-yasg

I have integrated swagger in django project using drf-yasg. Everything works fine on localhost but when deployed on development , swagger-ui css and js are not loading in browser. It gives the following error: Refused to apply style from…
0
votes
0 answers

Add filtering parameters in drf_yasg Swagger in django-rest-framework Viewsets

I am using django-rest-framework Viewset and i have one list API in that i have to add filtering parameters start_date and end_date in request body in swagger. class SchoolManagementView(ViewSet): def __init__(self, *args, **kwargs): …
0
votes
1 answer

Django How to use drf-yasg in class-base view which is parent of all other views to generate swagger docs?

I'm using drf-yasg for swagger docs, but I'm using a BaseView which is the parent class view for all other views, thus all HTTP methods are written in BaseView so that children views don't need to implement these methods. the problem is that when I…
0
votes
0 answers

How to limit some endpoints w.r.t logged in user in swagger `drf-yasg`?

I have setup drf-yasg, but unable to limit some endpoints for specific users only. Tried using public=False, but how to tell it that which users should see which of the endpoints ? schema_view = get_schema_view(openapi.Info( title="API…
S.K
  • 480
  • 1
  • 4
  • 19
0
votes
1 answer

is there a way to provide custom names for my drf-yasg endpoints?

i am implementing an API using django-rest-framework and using drf-yasg to document and name my endpoints every post method ends with create i tried searching through the documentation and i cant find a way to do it
0
votes
0 answers

Is there a way to set default empty string "" parameter in swagger - django rest framework?

I use drf-yasg to generate swagger documentation for my api. I would want set empty "" string instead "string" as default. How can I do? properties = { 'type_operator': openapi.Schema(type=openapi.TYPE_INTEGER, description="L'operatore di…
zabitstack
  • 155
  • 1
  • 6
0
votes
0 answers

generate swagger documentation that depend GET parameter in drf-yasg

I want generate swagger documentation for drf that depend from one parameter sent in POST. If essource(this parameter) == 1 I want list of (from a database named "civile") field_1 field_2 ... field_10 If instead essource == 2 I want other parameters…
zabitstack
  • 155
  • 1
  • 6
0
votes
0 answers

how do you pass a parameter from post method to decorator?

I'm working a python django and django rest framework + swagger (drf-yasg) project. I need a dynamic decorator. how do you pass a parameter(named in this case "essource") of post method to decorator? def xxx(esSource): source = {} if…
0
votes
0 answers

how to make drf-yasg generate schema to add accept content type application/json for all the requests

I want to add to all the paths that generated automatically by drf-yasg accept content type application/json by default. something like: "requestBody": { "content": { "application/json": { "schema": { …
0
votes
1 answer

Defining custom request - Swagger (Drf-yasg)

I have a use case, where the request required fields are different depending on one of the field values of the request. For example, if the value of the movable type in the request is 'P', then some fields are mandatory, otherwise, if the value of…
S.K
  • 480
  • 1
  • 4
  • 19
0
votes
0 answers

django rest ViewAPI parameters not displayed in OpenAPI dynamic schema

I want to make a swagger document of my project, so I tried to generate a dynamic schema for my APIs, using django rest automatic dynamic generated schema, as said in its document. This is my urls.py: from django.urls import path, include from…
0
votes
1 answer

Override template swagger UI Header name and icon, drf-yasg

I'm trying to customize the swagger ui. I already override the template by adding drf-yasg/swagger-ui.html on templates. When I tried to add a header tag It just add above it. here's the code from swagger-ui.html {% load static %}
0
votes
0 answers

Hide specific field in drf_yasg django swagger documentation

I have a project with drf_yasg, there is a serializer with a to_internal_value method which is writing a field('mobile_operator_code') for me. The field is overriden, so we don't need to input it in request. Though we need to output it in…
0
votes
1 answer

With drf-yasg, how can i show multiple openapi schemes?

Used: Django 2.2, drf-yasg 1.17.1, python 3.9 How can I show with drf-yasg multiple openapi schemes? API returning different responses, depending on the request. Basic response: Is it possible in drf-yasg to show responses like this? In the yaml…