mirror of
https://github.com/oceanprotocol/docs.git
synced 2024-11-26 19:49:26 +01:00
use pet store as example, output data from the depths of swagger json files
This commit is contained in:
parent
ae7e16a932
commit
a2252e10a5
@ -11,6 +11,10 @@
|
||||
url: /api/aquarius/
|
||||
|
||||
- name: brizo
|
||||
links:
|
||||
- name: API reference
|
||||
url: /api/brizo/
|
||||
|
||||
- name: pleuston
|
||||
|
||||
- group: Libraries
|
||||
|
@ -17,3 +17,8 @@
|
||||
items:
|
||||
- title: API reference
|
||||
link: /api/brizo/
|
||||
|
||||
- group: pet store
|
||||
items:
|
||||
- title: API reference
|
||||
link: /api/petstore/
|
||||
|
@ -155,16 +155,16 @@ exports.createPages = ({ graphql, actions }) => {
|
||||
'./src/templates/ApiSwagger.jsx'
|
||||
)
|
||||
|
||||
const brizoSlug = '/api/brizo/'
|
||||
const petStoreSlug = '/api/petstore/'
|
||||
|
||||
try {
|
||||
const spec = await getSpec()
|
||||
|
||||
createPage({
|
||||
path: brizoSlug,
|
||||
path: petStoreSlug,
|
||||
component: apiSwaggerTemplate,
|
||||
context: {
|
||||
slug: brizoSlug,
|
||||
slug: petStoreSlug,
|
||||
api: spec
|
||||
}
|
||||
})
|
||||
@ -172,29 +172,29 @@ exports.createPages = ({ graphql, actions }) => {
|
||||
console.log(error)
|
||||
}
|
||||
|
||||
// const aquariusSpecs = require('./data/aquarius.json')
|
||||
// const aquariusSlug = '/api/aquarius/'
|
||||
const aquariusSpecs = require('./data/aquarius.json')
|
||||
const aquariusSlug = '/api/aquarius/'
|
||||
|
||||
// createPage({
|
||||
// path: aquariusSlug,
|
||||
// component: apiSwaggerTemplate,
|
||||
// context: {
|
||||
// slug: aquariusSlug,
|
||||
// api: aquariusSpecs
|
||||
// }
|
||||
// })
|
||||
createPage({
|
||||
path: aquariusSlug,
|
||||
component: apiSwaggerTemplate,
|
||||
context: {
|
||||
slug: aquariusSlug,
|
||||
api: aquariusSpecs
|
||||
}
|
||||
})
|
||||
|
||||
// const brizoSpecs = require('./data/brizo.json')
|
||||
// const brizoSlug = '/api/brizo/'
|
||||
const brizoSpecs = require('./data/brizo.json')
|
||||
const brizoSlug = '/api/brizo/'
|
||||
|
||||
// createPage({
|
||||
// path: brizoSlug,
|
||||
// component: apiSwaggerTemplate,
|
||||
// context: {
|
||||
// slug: brizoSlug,
|
||||
// api: brizoSpecs
|
||||
// }
|
||||
// })
|
||||
createPage({
|
||||
path: brizoSlug,
|
||||
component: apiSwaggerTemplate,
|
||||
context: {
|
||||
slug: brizoSlug,
|
||||
api: brizoSpecs
|
||||
}
|
||||
})
|
||||
|
||||
resolve()
|
||||
})
|
||||
|
@ -38,7 +38,6 @@
|
||||
&:last-child {
|
||||
flex-basis: 100%;
|
||||
text-align: center;
|
||||
opacity: .75;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -272,6 +272,10 @@ samp {
|
||||
font-size: $font-size-small !important;
|
||||
border-radius: $border-radius !important;
|
||||
text-shadow: none !important;
|
||||
|
||||
h1 &, h2 &, h3 &, h4 &, h5 & {
|
||||
font-size: inherit !important;
|
||||
}
|
||||
}
|
||||
|
||||
:not(pre) > code {
|
||||
|
@ -11,6 +11,17 @@ import SEO from '../components/Seo'
|
||||
import stylesDoc from './Doc.module.scss'
|
||||
// import styles from './ApiSwagger.module.scss'
|
||||
|
||||
const toc = api => {
|
||||
const items = Object.keys(api.paths).map(
|
||||
key =>
|
||||
`<li key=${key}>
|
||||
<a href="#${key.replace(/\//gi, '-')}"><code>${key}</code></a>
|
||||
</li>`
|
||||
)
|
||||
|
||||
return `<ul>${items}</ul>`
|
||||
}
|
||||
|
||||
export default class ApiSwaggerTemplate extends Component {
|
||||
static propTypes = {
|
||||
data: PropTypes.object.isRequired,
|
||||
@ -55,6 +66,10 @@ export default class ApiSwaggerTemplate extends Component {
|
||||
location={location}
|
||||
sidebar={'api'}
|
||||
collapsed
|
||||
toc
|
||||
tableOfContents={toc(api)
|
||||
.split(',')
|
||||
.join('')}
|
||||
/>
|
||||
</aside>
|
||||
<article className={stylesDoc.main}>
|
||||
@ -65,11 +80,31 @@ export default class ApiSwaggerTemplate extends Component {
|
||||
|
||||
{version}
|
||||
|
||||
{Object.keys(api.paths).map(key => (
|
||||
<>
|
||||
<h2 key={key}>{key}</h2>
|
||||
</>
|
||||
))}
|
||||
{Object.entries(api.paths).map(
|
||||
([key, value]) => (
|
||||
<>
|
||||
<h2
|
||||
key={key}
|
||||
id={key.replace(/\//gi, '-')}
|
||||
>
|
||||
<code>{key}</code>
|
||||
</h2>
|
||||
|
||||
{Object.entries(value).map(
|
||||
([key, value]) => (
|
||||
<>
|
||||
<h4 key={key}>
|
||||
<code>{key}</code>
|
||||
</h4>
|
||||
<p>
|
||||
{value['summary']}
|
||||
</p>
|
||||
</>
|
||||
)
|
||||
)}
|
||||
</>
|
||||
)
|
||||
)}
|
||||
</article>
|
||||
</main>
|
||||
</Content>
|
||||
|
Loading…
Reference in New Issue
Block a user