1
0
mirror of https://github.com/oceanprotocol/docs.git synced 2024-11-26 19:49:26 +01:00

Feature: Add sample api responses

This commit is contained in:
Akshay 2021-08-08 18:27:25 +02:00
parent 3d14f33d7d
commit 44d1c18136

View File

@ -35,10 +35,10 @@ const ParameterExample = ({ properties }) => (
)} )}
{(properties[key].type === 'integer' || {(properties[key].type === 'integer' ||
properties[key].type === 'number') && ( properties[key].type === 'number') && (
<span className="token number"> <span className="token number">
{`${properties[key].example}`} {`${properties[key].example}`}
</span> </span>
)} )}
{(properties[key].type === 'array' || {(properties[key].type === 'array' ||
properties[key].type === 'object') && properties[key].type === 'object') &&
JSON.stringify(properties[key].example, null, 2)} JSON.stringify(properties[key].example, null, 2)}
@ -117,29 +117,38 @@ const ResponseExample = ({ examples }) => {
<b>Example</b> <b>Example</b>
<br /> <br />
<code> <code>
{typeof jsonExample == "boolean" ? <code>{JSON.stringify(jsonExample)}</code> : <ReactJson {typeof jsonExample === 'boolean' ? (
name={null} <code>{JSON.stringify(jsonExample)}</code>
src={jsonExample} ) : (
collapsed <ReactJson
enableClipboard={false} name={null}
/>} src={jsonExample}
collapsed
enableClipboard={false}
/>
)}
</code> </code>
</div> </div>
) )
} else if (plainText) { } else if (plainText) {
return <div><b>Example</b><code>{plainText}</code></div> return (
<div>
<b>Example</b>
<code>{plainText}</code>
</div>
)
} }
return null return null
} }
ResponseExample.propTypes = { ResponseExample.propTypes = {
example: PropTypes.object examples: PropTypes.object
} }
const Method = ({ keyName, value }) => { const Method = ({ keyName, value }) => {
const { summary, description, parameters, responses } = value const { summary, description, parameters, responses } = value
console.log("---", summary, responses) console.log('---', summary, responses)
return ( return (
<div className={styles.method}> <div className={styles.method}>
<h3 className={styles.pathMethod} data-type={keyName}> <h3 className={styles.pathMethod} data-type={keyName}>