How to integrate swagger-ui with Django Rest Framework and Django-Rest-framwork-Swagger?

1.4k Views Asked by At

I am writing a Django app that exposes an API via DRF. Normally, I would generate the schema from code and expose the API docs via swagger-ui and the django rest framework swagger plugin for Django. The plugin uses 2 renderes to do so like:

schema_view = get_schema_view( title='app api title', renderer_classes=[OpenAPIRenderer, SwaggerUIRenderer] )

My use case is a bit different this time. What I am trying to do is to render an already existing swagger.yml (I dont want to generate this dynamically from code). I guessed one needs to inject the existing swagger.yml into the SwaggerUIRenderer, but I failed to do so...

Is there any way to do this via the rest swagger plugin?

1

There are 1 best solutions below

1
On

If you already have a definition file you don't need to use django_rest_swagger plugin, you can simply use Swagger-UI as recommended in this iusse.

https://github.com/marcgibbons/django-rest-swagger/issues/567