diff --git a/gatsby-node.js b/gatsby-node.js index 0b460e52..345d51f1 100755 --- a/gatsby-node.js +++ b/gatsby-node.js @@ -202,7 +202,9 @@ const createTypeDocPage = async (createPage, name, downloadUrl) => { // https://github.com/swagger-api/swagger-js const fetchSwaggerSpec = async (component) => { try { - const client = await Swagger(`http://localhost:5000/spec`) + const client = await Swagger( + `https://${component}.mainnet.oceanprotocol.com/spec` + ) return client.spec // The resolved spec // client.originalSpec // In case you need it diff --git a/src/templates/Swagger/Paths.jsx b/src/templates/Swagger/Paths.jsx index 0f1d311e..56e01daf 100644 --- a/src/templates/Swagger/Paths.jsx +++ b/src/templates/Swagger/Paths.jsx @@ -4,9 +4,7 @@ import slugify from 'slugify' import { cleanPathKey } from './utils' import styles from './Paths.module.scss' import stylesDoc from '../Doc.module.scss' -const ResponseExample = React.lazy(() => - import("./ResponseExample") -) +const ResponseExample = React.lazy(() => import('./ResponseExample')) const ParameterExample = ({ properties }) => ( // // HEADS UP! @@ -36,10 +34,10 @@ const ParameterExample = ({ properties }) => ( )} {(properties[key].type === 'integer' || properties[key].type === 'number') && ( - - {`${properties[key].example}`} - - )} + + {`${properties[key].example}`} + + )} {(properties[key].type === 'array' || properties[key].type === 'object') && JSON.stringify(properties[key].example, null, 2)} @@ -91,24 +89,26 @@ Parameters.propTypes = { } const Responses = ({ responses }) => { - const isSSR = typeof window === "undefined" + const isSSR = typeof window === 'undefined' - return (<> -

Responses

- {Object.keys(responses).map((key) => ( -
- {key} {responses[key].description} -
- <> - {!isSSR && ( - }> - - - )} - -
- ))} - ) + return ( + <> +

Responses

+ {Object.keys(responses).map((key) => ( +
+ {key} {responses[key].description} +
+ <> + {!isSSR && ( + }> + + + )} + +
+ ))} + + ) } Responses.propTypes = { diff --git a/src/templates/Swagger/ResponseExample.jsx b/src/templates/Swagger/ResponseExample.jsx index 974b1452..579a2cf8 100644 --- a/src/templates/Swagger/ResponseExample.jsx +++ b/src/templates/Swagger/ResponseExample.jsx @@ -1,48 +1,46 @@ -import React from "react" -import PropTypes from "prop-types" +import React from 'react' +import PropTypes from 'prop-types' import ReactJson from 'react-json-view' - const ResponseExample = ({ examples }) => { + if (!examples) return null + const jsonExample = examples['application/json'] + const plainText = examples['text/plain'] - if (!examples) return null - const jsonExample = examples['application/json'] - const plainText = examples['text/plain'] - - if (typeof document !== `undefined`) { - if (jsonExample) { - return ( -
- Example -
- - {typeof jsonExample === 'boolean' ? ( - {JSON.stringify(jsonExample)} - ) : ( - - )} - -
- ) - } else if (plainText) { - return ( -
- Example - {plainText} -
- ) - } + if (typeof document !== `undefined`) { + if (jsonExample) { + return ( +
+ Example +
+ + {typeof jsonExample === 'boolean' ? ( + {JSON.stringify(jsonExample)} + ) : ( + + )} + +
+ ) + } else if (plainText) { + return ( +
+ Example + {plainText} +
+ ) } - return null + } + return null } ResponseExample.propTypes = { - examples: PropTypes.object + examples: PropTypes.object } -export default ResponseExample \ No newline at end of file +export default ResponseExample