Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion frontend/knip.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import type { KnipConfig } from "knip";
export default {
entry: [
"src/main.tsx",
"src/swagger.tsx",
"src/swagger.ts",
"src/routes/*",
"i18next-parser.config.ts",
],
Expand Down
10 changes: 6 additions & 4 deletions frontend/src/swagger.tsx → frontend/src/swagger.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
// SPDX-License-Identifier: AGPL-3.0-only
// Please see LICENSE in the repository root for full details.

import { SwaggerUIBundle, SwaggerUIStandalonePreset } from "swagger-ui-dist";
import { SwaggerUIBundle } from "swagger-ui-dist";
import "swagger-ui-dist/swagger-ui.css";

type ApiConfig = {
Expand All @@ -14,16 +14,18 @@ type ApiConfig = {

interface IWindow {
API_CONFIG?: ApiConfig;
ui?: SwaggerUIBundle;
}

const config = typeof window !== "undefined" && (window as IWindow).API_CONFIG;
if (!config) {
throw new Error("API_CONFIG is not defined");
}

SwaggerUIBundle({
url: "./spec.json",
(window as IWindow).ui = SwaggerUIBundle({
url: config.openapiUrl,
oauth2RedirectUrl: config.callbackUrl,
dom_id: "#swagger-ui",
deepLinking: true,
presets: [SwaggerUIStandalonePreset],
presets: [SwaggerUIBundle.presets.apis],
});
2 changes: 1 addition & 1 deletion frontend/vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ export default defineConfig((env) => ({
resolve(__dirname, "src/main.tsx"),
resolve(__dirname, "src/shared.css"),
resolve(__dirname, "src/templates.css"),
resolve(__dirname, "src/swagger.tsx"),
resolve(__dirname, "src/swagger.ts"),
],
},
},
Expand Down
4 changes: 2 additions & 2 deletions templates/swagger/doc.html
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@
callbackUrl: "{{ callback_url | add_slashes | safe }}",
};
</script>
{{ include_asset('src/swagger.tsx') | indent(4) | safe }}
{{ include_asset('src/swagger.ts') | indent(4) | safe }}
</head>

<body>
<div id="root"></div>
<div id="swagger-ui"></div>
</body>
</html>
Loading