{% load static %}
<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <title>{{ title|default:"Swagger UI" }}</title>
  {% if swagger_cdn %}
    <link rel="stylesheet" type="text/css" href="{{ swagger_cdn }}/swagger-ui.css" />
  {% else %}
    <link rel="stylesheet" type="text/css" href="{% static 'dmr/swagger/5.32.1/swagger-ui.css' %}" />
    <link rel="stylesheet" type="text/css" href="{% static 'dmr/swagger/5.32.1/index.css' %}" />
    <link rel="icon" type="image/png" href="{% static 'dmr/swagger/5.32.1/favicon-32x32.png' %}" sizes="32x32" />
    <link rel="icon" type="image/png" href="{% static 'dmr/swagger/5.32.1/favicon-16x16.png' %}" sizes="16x16" />
  {% endif %}
</head>

<body>
  <div id="swagger-ui"></div>
  {% if swagger_cdn %}
    <script src="{{ swagger_cdn }}/swagger-ui-bundle.js" charset="UTF-8"> </script>
    <script src="{{ swagger_cdn }}/swagger-ui-standalone-preset.js" charset="UTF-8"> </script>
  {% else %}
    <script src="{% static 'dmr/swagger/5.32.1/swagger-ui-bundle.js' %}" charset="UTF-8"> </script>
    <script src="{% static 'dmr/swagger/5.32.1/swagger-ui-standalone-preset.js' %}" charset="UTF-8"> </script>
  {% endif %}
  <script>
    window.onload = function () {
      window.ui = SwaggerUIBundle({
        spec: {{ schema | safe }},
        dom_id: '#swagger-ui',
        deepLinking: true,
        presets: [
          SwaggerUIBundle.presets.apis,
          SwaggerUIStandalonePreset
        ],
        plugins: [
          SwaggerUIBundle.plugins.DownloadUrl
        ],
        layout: "StandaloneLayout",
        requestInterceptor: (req) => {
          req.headers['X-CSRFToken'] = '{{ csrf_token }}';
          return req;
        }
      });
    };
  </script>
</body>

</html>
