mirror of
https://github.com/shishantbiswas/bknd.git
synced 2026-03-17 12:56:05 +00:00
43 lines
1.2 KiB
TypeScript
43 lines
1.2 KiB
TypeScript
import { useEffect } from "react";
|
|
import { Scrollable } from "ui/layouts/AppShell/AppShell";
|
|
|
|
function SwaggerUI() {
|
|
useEffect(() => {
|
|
// Create a script element to load the Swagger UI bundle
|
|
const script = document.createElement("script");
|
|
script.src = "https://unpkg.com/swagger-ui-dist@5.11.0/swagger-ui-bundle.js";
|
|
script.crossOrigin = "anonymous";
|
|
script.async = true;
|
|
|
|
// Append the script to the body and set up Swagger UI once loaded
|
|
script.onload = () => {
|
|
// @ts-ignore
|
|
if (window.SwaggerUIBundle) {
|
|
// @ts-ignore
|
|
window.ui = window.SwaggerUIBundle({
|
|
url: "http://localhost:28623/api/system/openapi.json",
|
|
dom_id: "#swagger-ui"
|
|
});
|
|
}
|
|
};
|
|
|
|
document.body.appendChild(script);
|
|
|
|
// Cleanup script on unmount
|
|
return () => {
|
|
document.body.removeChild(script);
|
|
};
|
|
}, []);
|
|
|
|
return (
|
|
<>
|
|
<link rel="stylesheet" href="https://unpkg.com/swagger-ui-dist@5.11.0/swagger-ui.css" />
|
|
<Scrollable>
|
|
<div id="swagger-ui" />
|
|
</Scrollable>
|
|
</>
|
|
);
|
|
}
|
|
|
|
export default SwaggerUI;
|