How to show API description with django_rest_swagger 2.1.1

1.4k Views Asked by At

For 0.3 version, DRF is able to read info data in Swagger settings and render it in Swagger UI.

SWAGGER_SETTINGS = 
{  
......  
"info": {  
    'contact': '[email protected]',   
    'description': 'This document intends to describe all Restful APIs.',  
    'title': 'GSLB API document',  
     },  
"USE_SESSION_AUTH": True  
}

But for version 2.1.1, it seems the info field is not supported in swagger_settings? The title can be passed as follows:

schema_view = get_swagger_view(title='My Restful API')

But it seems there is no way to pass the description to get_swagger_view, thus I am not able to show a description on Swagger UI. Is there a workaround in this version? Thanks.

1

There are 1 best solutions below

0
On

For current versions of Django Rest Framework Swagger, adding docstring comments seems to work (e.g., they show as descriptions in Swagger docs).

class MyExport(mixins.ListModelMixin, viewsets.GenericViewSet): """ A really cool function"""

And "A really cool function" shows as the description in swagger view.