<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <title>{{ title }} {{ version }} - Swagger UI</title>
    <link rel="stylesheet" type="text/css" href="{{ config.SWAGGER_UI_CSS }}">
    <link rel="icon" type="image/png" href="{{ config.DOCS_FAVICON or url_for('openapi.static', filename='favicon.png') }}">
    <style>
        html {
            box-sizing: border-box;
            overflow: -moz-scrollbars-vertical;
            overflow-y: scroll;
        }

        *,
        *:before,
        *:after {
            box-sizing: inherit;
        }

        body {
            margin: 0;
            background: #fafafa;
        }
    </style>
</head>

<body>
    <div id="swagger-ui"></div>

    <script src="{{ config.SWAGGER_UI_BUNDLE_JS }}"></script>
    <script src="{{ config.SWAGGER_UI_STANDALONE_PRESET_JS }}"></script>
    <script>
        var baseConfig = {
            url: "{{ url_for('openapi.spec') }}",
            dom_id: '#swagger-ui',
            deepLinking: true,
            presets: [
                SwaggerUIBundle.presets.apis,
                SwaggerUIStandalonePreset
            ],
            plugins: [
                SwaggerUIBundle.plugins.DownloadUrl
            ],
            layout: "{{ config.SWAGGER_UI_LAYOUT }}",
            {% if oauth2_redirect_path %}oauth2RedirectUrl: "{{ oauth2_redirect_path }}"{% endif %}
        }
        {% if config.SWAGGER_UI_CONFIG %}
        var userConfig = {{ config.SWAGGER_UI_CONFIG|tojson }}
        for (var attr in userConfig) {
            baseConfig[attr] = userConfig[attr]
        }
        {% endif %}
        window.onload = function () {
            const ui = SwaggerUIBundle(baseConfig)
            {% if config.SWAGGER_UI_OAUTH_CONFIG %}
            oauthConfig = {}
            var userOauthConfig = {{ config.SWAGGER_UI_OAUTH_CONFIG|tojson }}
            for (var attr in userOauthConfig) {
                oauthConfig[attr] = userOauthConfig[attr]
            }
            ui.initOAuth(oauthConfig)
            {% endif %}
        }
    </script>
</body>

</html>
