<!doctype html>
<html>

<head>
    <meta charset="utf-8" />
    <title>PROLAB API by HANUMANIT</title>
    <link rel="stylesheet" href="https://unpkg.com/swagger-ui-dist/swagger-ui.css" />
    <style>
        body {
            margin: 0
        }
    </style>
</head>

<body>
    <div id="swagger-ui"></div>
    <script src="https://unpkg.com/swagger-ui-dist/swagger-ui-bundle.js"></script>
    <script>
        window.ui = SwaggerUIBundle({
            url: "/api-prolab/api/web/resource", // endpoint OpenAPI JSON
            dom_id: "#swagger-ui",
            deepLinking: true,
            presets: [SwaggerUIBundle.presets.apis],
            requestInterceptor: (req) => {
                const token = localStorage.getItem("auth_token");
                if (token) {
                    req.headers['Authorization'] = `Bearer ${token}`;
                }
                return req;
            },
            docExpansion: "none",
            defaultModelsExpandDepth: -1,
            plugins: [
                function HideCustomSchemas() {
                    return {
                        statePlugins: {
                            spec: {
                                wrapSelectors: {
                                    specJson: (ori) => (state, system) => {
                                        const json = ori(state, system);
                                        if (json.components && json.components.schemas) {
                                            for (const [key, schema] of Object.entries(json.components.schemas)) {
                                                if (schema['x-hideInUI']) delete json.components.schemas[key];
                                            }
                                        }
                                        return json;
                                    }
                                }
                            }
                        }
                    };
                }
            ]
        });
    </script>
</body>

</html>