How can I add Redoc documentation to the Django using local yml schema file?

Viewed 622

Does anyone know how can I add Redoc documentation endpoint using local schema.yml file? In the Swagger I do something like shown below unfortunately I have a problem with Redoc. Any ideas?

urls.py:

path('', TemplateView.as_view(
    template_name='swagger-ui.html',
    extra_context={'schema_url': 'openapi-schema'}
), name='swagger-ui'),

swagger-ui.html:

{% load static %}
<html>
  <head>
    <title>Documentation</title>
    <meta charset="utf-8"/>
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <link rel="stylesheet" type="text/css" href="//unpkg.com/swagger-ui-dist@3/swagger-ui.css" />
  </head>
  <body>
    <div id="swagger-ui"></div>
    <script src="//unpkg.com/swagger-ui-dist@3/swagger-ui-bundle.js"></script>
    <script>
   const ui = SwaggerUIBundle({
    url: "{% static 'schema.yml' %}",
    dom_id: '#swagger-ui',
    presets: [
      SwaggerUIBundle.presets.apis,
      SwaggerUIBundle.SwaggerUIStandalonePreset
    ],
  })
    </script>
  </body>
</html>
0 Answers
Related