You've already forked authentication-service
mirror of
https://github.com/matrix-org/matrix-authentication-service.git
synced 2025-07-29 22:01:14 +03:00
Host a Swagger UI both in the static documentation and by the server
This commit is contained in:
2365
frontend/package-lock.json
generated
2365
frontend/package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@ -37,6 +37,7 @@
|
||||
"react": "^18.3.1",
|
||||
"react-dom": "^18.3.1",
|
||||
"react-i18next": "^14.1.2",
|
||||
"swagger-ui-react": "^5.17.14",
|
||||
"urql": "^4.1.0",
|
||||
"vaul": "^0.9.1",
|
||||
"zod": "^3.23.8"
|
||||
@ -60,6 +61,7 @@
|
||||
"@types/react": "^18.3.3",
|
||||
"@types/react-dom": "^18.3.0",
|
||||
"@types/react-test-renderer": "^18.3.0",
|
||||
"@types/swagger-ui-react": "^4.18.3",
|
||||
"@vitejs/plugin-react": "^4.3.1",
|
||||
"@vitest/coverage-v8": "^1.6.0",
|
||||
"autoprefixer": "^10.4.19",
|
||||
|
35
frontend/src/swagger.tsx
Normal file
35
frontend/src/swagger.tsx
Normal file
@ -0,0 +1,35 @@
|
||||
// Copyright 2024 The Matrix.org Foundation C.I.C.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
import { createRoot } from "react-dom/client";
|
||||
import SwaggerUI from "swagger-ui-react";
|
||||
import "swagger-ui-react/swagger-ui.css";
|
||||
|
||||
type ApiConfig = {
|
||||
openapiUrl: string;
|
||||
callbackUrl: string;
|
||||
};
|
||||
|
||||
interface IWindow {
|
||||
API_CONFIG?: ApiConfig;
|
||||
}
|
||||
|
||||
const config = typeof window !== "undefined" && (window as IWindow).API_CONFIG;
|
||||
if (!config) {
|
||||
throw new Error("API_CONFIG is not defined");
|
||||
}
|
||||
|
||||
createRoot(document.getElementById("root") as HTMLElement).render(
|
||||
<SwaggerUI url={config.openapiUrl} oauth2RedirectUrl={config.callbackUrl} />,
|
||||
);
|
@ -65,6 +65,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"),
|
||||
],
|
||||
},
|
||||
},
|
||||
|
Reference in New Issue
Block a user