I went through Django REST Swagger 2.1.2 documentation. When I tried with class based views, it was working fine.
But i did not find any reference on how to enable swagger for function based views as shown below:
@api_view(['GET', 'POST'])
def app_info(request):
...
return response
Most of my views.py
is filled with function based views, just like above.
Any help on how to enable the same will greatly appreciated. Thanks!
I am using Django: 1.8; Django REST Swagger: 2.1.2; DRF: 3.6.2
You should be able to use
@renderer_classes
decorator:Also, it should be worth mentioning, that if you don't want to use this decorator on every view you can specify
DEFAULT_RENDERER_CLASSES
in settingsEDIT: It seems it's in the docs after all. Check the very bottom of this page: https://django-rest-swagger.readthedocs.io/en/latest/schema/
i am not fammiliar with swagger,but you may try to use the decorator in this way:
or
----------------------------------------------------------------------------
sorry, maybe i have misunderstood your question. according to the document, if you want to enable swagger in class based view. there is example:
restframework will use these two renderer_classes to render Json and UI.