1
0
mirror of https://github.com/oceanprotocol/docs.git synced 2024-11-02 16:25:37 +01:00

Feature: Add sample api responses

This commit is contained in:
Akshay 2021-08-08 18:22:26 +02:00
parent acc3ac20ae
commit 3d14f33d7d

View File

@ -35,10 +35,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)}
@ -109,23 +109,28 @@ Responses.propTypes = {
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>
{' '}
<ReactJson
{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 = {
@ -134,6 +139,7 @@ ResponseExample.propTypes = {
const Method = ({ keyName, value }) => {
const { summary, description, parameters, responses } = value
console.log("---", summary, responses)
return (
<div className={styles.method}>
<h3 className={styles.pathMethod} data-type={keyName}>