mirror of
https://github.com/oceanprotocol/docs.git
synced 2024-11-26 19:49:26 +01:00
Fix build issue
This commit is contained in:
parent
44d1c18136
commit
cda2edcc01
@ -202,9 +202,7 @@ const createTypeDocPage = async (createPage, name, downloadUrl) => {
|
||||
// https://github.com/swagger-api/swagger-js
|
||||
const fetchSwaggerSpec = async (component) => {
|
||||
try {
|
||||
const client = await Swagger(
|
||||
`https://${component}.mainnet.oceanprotocol.com/spec`
|
||||
)
|
||||
const client = await Swagger(`http://localhost:5000/spec`)
|
||||
return client.spec // The resolved spec
|
||||
|
||||
// client.originalSpec // In case you need it
|
||||
|
@ -4,8 +4,9 @@ import slugify from 'slugify'
|
||||
import { cleanPathKey } from './utils'
|
||||
import styles from './Paths.module.scss'
|
||||
import stylesDoc from '../Doc.module.scss'
|
||||
import ReactJson from 'react-json-view'
|
||||
|
||||
const ResponseExample = React.lazy(() =>
|
||||
import("./ResponseExample")
|
||||
)
|
||||
const ParameterExample = ({ properties }) => (
|
||||
//
|
||||
// HEADS UP!
|
||||
@ -35,10 +36,10 @@ const ParameterExample = ({ properties }) => (
|
||||
)}
|
||||
{(properties[key].type === 'integer' ||
|
||||
properties[key].type === 'number') && (
|
||||
<span className="token number">
|
||||
{`${properties[key].example}`}
|
||||
</span>
|
||||
)}
|
||||
<span className="token number">
|
||||
{`${properties[key].example}`}
|
||||
</span>
|
||||
)}
|
||||
{(properties[key].type === 'array' ||
|
||||
properties[key].type === 'object') &&
|
||||
JSON.stringify(properties[key].example, null, 2)}
|
||||
@ -89,63 +90,31 @@ Parameters.propTypes = {
|
||||
parameters: PropTypes.array.isRequired
|
||||
}
|
||||
|
||||
const Responses = ({ responses }) => (
|
||||
<>
|
||||
const Responses = ({ responses }) => {
|
||||
const isSSR = typeof window === "undefined"
|
||||
|
||||
return (<>
|
||||
<h4 className={styles.subHeading}>Responses</h4>
|
||||
{Object.keys(responses).map((key) => (
|
||||
<div key={key} className={styles.response}>
|
||||
<code>{key}</code> {responses[key].description}
|
||||
<br />
|
||||
<ResponseExample examples={responses[key].example} />
|
||||
<>
|
||||
{!isSSR && (
|
||||
<React.Suspense fallback={<div />}>
|
||||
<ResponseExample examples={responses[key].example} />
|
||||
</React.Suspense>
|
||||
)}
|
||||
</>
|
||||
</div>
|
||||
))}
|
||||
</>
|
||||
)
|
||||
</>)
|
||||
}
|
||||
|
||||
Responses.propTypes = {
|
||||
responses: PropTypes.object.isRequired
|
||||
}
|
||||
|
||||
const ResponseExample = ({ examples }) => {
|
||||
if (!examples) return null
|
||||
const jsonExample = examples['application/json']
|
||||
const plainText = examples['text/plain']
|
||||
|
||||
if (jsonExample) {
|
||||
return (
|
||||
<div>
|
||||
<b>Example</b>
|
||||
<br />
|
||||
<code>
|
||||
{typeof jsonExample === 'boolean' ? (
|
||||
<code>{JSON.stringify(jsonExample)}</code>
|
||||
) : (
|
||||
<ReactJson
|
||||
name={null}
|
||||
src={jsonExample}
|
||||
collapsed
|
||||
enableClipboard={false}
|
||||
/>
|
||||
)}
|
||||
</code>
|
||||
</div>
|
||||
)
|
||||
} else if (plainText) {
|
||||
return (
|
||||
<div>
|
||||
<b>Example</b>
|
||||
<code>{plainText}</code>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
return null
|
||||
}
|
||||
|
||||
ResponseExample.propTypes = {
|
||||
examples: PropTypes.object
|
||||
}
|
||||
|
||||
const Method = ({ keyName, value }) => {
|
||||
const { summary, description, parameters, responses } = value
|
||||
console.log('---', summary, responses)
|
||||
|
48
src/templates/Swagger/ResponseExample.jsx
Normal file
48
src/templates/Swagger/ResponseExample.jsx
Normal file
@ -0,0 +1,48 @@
|
||||
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 (typeof document !== `undefined`) {
|
||||
if (jsonExample) {
|
||||
return (
|
||||
<div>
|
||||
<b>Example</b>
|
||||
<br />
|
||||
<code>
|
||||
{typeof jsonExample === 'boolean' ? (
|
||||
<code>{JSON.stringify(jsonExample)}</code>
|
||||
) : (
|
||||
<ReactJson
|
||||
name={null}
|
||||
src={jsonExample}
|
||||
collapsed
|
||||
enableClipboard={false}
|
||||
/>
|
||||
)}
|
||||
</code>
|
||||
</div>
|
||||
)
|
||||
} else if (plainText) {
|
||||
return (
|
||||
<div>
|
||||
<b>Example</b>
|
||||
<code>{plainText}</code>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
}
|
||||
return null
|
||||
}
|
||||
|
||||
ResponseExample.propTypes = {
|
||||
examples: PropTypes.object
|
||||
}
|
||||
|
||||
export default ResponseExample
|
Loading…
Reference in New Issue
Block a user