mirror of
https://github.com/shishantbiswas/bknd.git
synced 2026-03-18 05:16:04 +00:00
public commit
This commit is contained in:
42
app/src/ui/routes/test/tests/swagger-test.tsx
Normal file
42
app/src/ui/routes/test/tests/swagger-test.tsx
Normal file
@@ -0,0 +1,42 @@
|
||||
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;
|
||||
Reference in New Issue
Block a user