Skip to content

Commit

Permalink
Fix: Loading swagger UI by using javascript script loading
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 8fdc0b9 commit 165c9be
Show file tree
Hide file tree
Showing 8 changed files with 93 additions and 55 deletions.
1 change: 0 additions & 1 deletion src/components/Header/index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import React from 'react';
import Translate from '@docusaurus/Translate';
import styles from './../../pages/index.module.css';
import clsx from 'clsx';

export default function Header() {
Expand Down
22 changes: 0 additions & 22 deletions src/pages/data-intermediation.js

This file was deleted.

22 changes: 0 additions & 22 deletions src/pages/data-marketplace.js

This file was deleted.

39 changes: 39 additions & 0 deletions src/pages/dataintermediation.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
import React from 'react';
import useDocusaurusContext from '@docusaurus/useDocusaurusContext';
import Layout from '@theme/Layout';
import Footer from '@site/src/components/Footer';
import Helmet from "react-helmet";
import BrowserOnly from '@docusaurus/BrowserOnly';

export default function DataIntermediation() {
const { siteConfig } = useDocusaurusContext();
return (
<Layout
title={`${siteConfig.title}`}
description="Enabling trust in the data ecosystem for next-generation data sharing. ">
<Helmet>
<title>NordXDataspace (NXD)</title>
<link rel="stylesheet" href="https://unpkg.com/[email protected]/swagger-ui.css" />
</Helmet>
<div id="swagger-ui"></div>
<BrowserOnly>
{() => {

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 />
</Layout>
)
}
33 changes: 33 additions & 0 deletions src/pages/datamarketplace.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import React from 'react';
import useDocusaurusContext from '@docusaurus/useDocusaurusContext';
import Layout from '@theme/Layout';
import Footer from '@site/src/components/Footer';
import Helmet from "react-helmet";
import BrowserOnly from '@docusaurus/BrowserOnly';

export default function DataMarketplace() {
const { siteConfig } = useDocusaurusContext();
return (
<Layout
title={`${siteConfig.title}`}
description="Enabling trust in the data ecosystem for next-generation data sharing. ">
<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 = () => {
window.ui = SwaggerUIBundle({
url: '/openapi/datamarketplace.yaml',
dom_id: '#swagger-ui',
});
}
}}
</BrowserOnly>
<Footer />
</Layout>
)
}
21 changes: 16 additions & 5 deletions src/pages/domain.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
import React from 'react';
import useDocusaurusContext from '@docusaurus/useDocusaurusContext';
import Layout from '@theme/Layout';
import Footer from '../components/Footer';
import Footer from '@site/src/components/Footer';
import Helmet from "react-helmet";
import SwaggerUI from "swagger-ui-react"
import "swagger-ui-react/swagger-ui.css"
import BrowserOnly from '@docusaurus/BrowserOnly';

export default function Domain() {
const { siteConfig } = useDocusaurusContext();
Expand All @@ -14,9 +13,21 @@ export default function Domain() {
description="Enabling trust in the data ecosystem for next-generation data sharing. ">
<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>
<SwaggerUI url="openapi/data-marketplace.yaml" />
<div id="swagger-ui"></div>
<BrowserOnly>
{() => {
window.onload = () => {
window.ui = SwaggerUIBundle({
url: '/openapi/datamarketplace.yaml',
dom_id: '#swagger-ui',
});
}
}}
</BrowserOnly>
<Footer />
</Layout>
);
)
}
10 changes: 5 additions & 5 deletions src/pages/index.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
import React from 'react';
import useDocusaurusContext from '@docusaurus/useDocusaurusContext';
import Layout from '@theme/Layout';
import Footer from '../components/Footer';
import Footer from '@site/src/components/Footer';
import Helmet from "react-helmet";
import Card from '../components/Card';
import Header from '../components/Header';
import Card from '@site/src/components/Card';
import Header from '@site/src/components/Header';


const CardList = [
{
title: "Data Marketplace APIs",
link: "/data-marketplace",
link: "/datamarketplace",
description: (<>
Get started with dHDSI data marketplace APIs after onboarding to the dHDSI marketplace.
</>),
Expand All @@ -24,7 +24,7 @@ const CardList = [
},
{
title: "Data Intermediation Service Provider APIs",
link: "/data-intermediation",
link: "/dataintermediation",
description: (<>
Get started with Data Intermediatoon Service Provider (DISP) APIs (Consents, Data Exchange and Digital Walets)
</>),
Expand Down
File renamed without changes.

0 comments on commit 165c9be

Please sign in to comment.