Skip to content

Commit

Permalink
Fix: Loading Swagger UI JS script
Browse files Browse the repository at this point in the history
Signed-off-by: George J Padayatti <[email protected]>
  • Loading branch information
georgepadayatti committed Apr 2, 2024
1 parent b9e0b07 commit 4bab76d
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 6 deletions.
12 changes: 9 additions & 3 deletions src/pages/datamarketplace.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,23 @@ export default function DataMarketplace() {
<Helmet>
<title>NordXDataspace (NXD)</title>
<link rel="stylesheet" href="https://unpkg.com/[email protected]/swagger-ui.css" />
<script src="https://unpkg.com/[email protected]/swagger-ui-bundle.js" crossorigin></script>
</Helmet>
<div id="swagger-ui"></div>
<BrowserOnly>
{() => {
window.onload = () => {

const script = document.createElement("script");
script.src = 'https://unpkg.com/[email protected]/swagger-ui-bundle.js'; // whatever url you want here
script.charset = "utf-8";
script.crossOrigin = true;
script.async = false;
script.onload = function () {
window.ui = SwaggerUIBundle({
url: '/openapi/datamarketplace.yaml',
dom_id: '#swagger-ui',
});
}
};
document.head.appendChild(script);
}}
</BrowserOnly>
<Footer />
Expand Down
12 changes: 9 additions & 3 deletions src/pages/domain.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,23 @@ export default function Domain() {
<Helmet>
<title>NordXDataspace (NXD)</title>
<link rel="stylesheet" href="https://unpkg.com/[email protected]/swagger-ui.css" />
<script src="https://unpkg.com/[email protected]/swagger-ui-bundle.js" crossorigin></script>
</Helmet>
<div id="swagger-ui"></div>
<BrowserOnly>
{() => {
window.onload = () => {

const script = document.createElement("script");
script.src = 'https://unpkg.com/[email protected]/swagger-ui-bundle.js'; // whatever url you want here
script.charset = "utf-8";
script.crossOrigin = true;
script.async = false;
script.onload = function () {
window.ui = SwaggerUIBundle({
url: '/openapi/datamarketplace.yaml',
dom_id: '#swagger-ui',
});
}
};
document.head.appendChild(script);
}}
</BrowserOnly>
<Footer />
Expand Down

0 comments on commit 4bab76d

Please sign in to comment.