mirror of
https://github.com/oceanprotocol/docs.git
synced 2024-11-26 19:49:26 +01:00
prototype with swagger json files
This commit is contained in:
parent
d6e381de87
commit
a6e056b856
@ -1,12 +0,0 @@
|
||||
---
|
||||
title: squid-js
|
||||
description: API reference for squid-js.
|
||||
---
|
||||
|
||||
Hello Squid.
|
||||
|
||||
## Asset
|
||||
|
||||
### getId
|
||||
|
||||
### purchase
|
@ -4,7 +4,6 @@
|
||||
},
|
||||
"info":{
|
||||
"title":"Aquarius",
|
||||
"description": "Hello description",
|
||||
"version":"0.1.4"
|
||||
},
|
||||
"paths":{
|
||||
@ -202,6 +201,9 @@
|
||||
},
|
||||
{
|
||||
"description":"key or list of keys to sort the result",
|
||||
"example": {
|
||||
"value": 1
|
||||
},
|
||||
"in":"query",
|
||||
"name":"sort",
|
||||
"type":"object"
|
||||
|
197
data/brizo.json
Normal file
197
data/brizo.json
Normal file
@ -0,0 +1,197 @@
|
||||
{
|
||||
"definitions":{
|
||||
|
||||
},
|
||||
"info":{
|
||||
"title":"Brizo",
|
||||
"version":"1.0"
|
||||
},
|
||||
"paths":{
|
||||
"/api/v1/brizo/services/access/initialize":{
|
||||
"post":{
|
||||
"consumes":[
|
||||
"application/json"
|
||||
],
|
||||
"description":"",
|
||||
"parameters":[
|
||||
{
|
||||
"description":"Service agreement initialization.",
|
||||
"in":"body",
|
||||
"name":"body",
|
||||
"required":true,
|
||||
"schema":{
|
||||
"properties":{
|
||||
"consumerAddress":{
|
||||
"description":"Consumer address.",
|
||||
"example":"0x00a329c0648769A73afAc7F9381E08FB43dBEA72",
|
||||
"type":"string"
|
||||
},
|
||||
"did":{
|
||||
"description":"Identifier of the asset registered in ocean.",
|
||||
"example":"did:op:08a429b8529856d59867503f8056903a680935a76950bb9649785cc97869a43d",
|
||||
"type":"string"
|
||||
},
|
||||
"serviceAgreementId":{
|
||||
"description":"Identifier of the service agreement.",
|
||||
"example":"bb23s87856d59867503f80a690357406857698570b964ac8dcc9d86da4ada010",
|
||||
"type":"string"
|
||||
},
|
||||
"serviceDefinitionId":{
|
||||
"description":"Identifier of the service definition.",
|
||||
"example":"0",
|
||||
"type":"string"
|
||||
},
|
||||
"signature":{
|
||||
"description":"Signature",
|
||||
"example":"cade376598342cdae231321a0097876aeda656a567a67c6767fd8710129a9dc1",
|
||||
"type":"string"
|
||||
}
|
||||
},
|
||||
"required":[
|
||||
"did",
|
||||
"serviceAgreementId",
|
||||
"serviceDefinitionId",
|
||||
"signature",
|
||||
{
|
||||
"consumerAddress":null
|
||||
}
|
||||
],
|
||||
"type":"object"
|
||||
}
|
||||
}
|
||||
],
|
||||
"responses":{
|
||||
"201":{
|
||||
"description":"Service agreement initialize successfully."
|
||||
},
|
||||
"400":{
|
||||
"description":"One of the required attributes is missed."
|
||||
},
|
||||
"404":{
|
||||
"description":"Invalid signature."
|
||||
},
|
||||
"500":{
|
||||
"description":"Error"
|
||||
}
|
||||
},
|
||||
"summary":"Initialize the SLA between the puvblisher and the consumer.",
|
||||
"tags":[
|
||||
"services"
|
||||
]
|
||||
}
|
||||
},
|
||||
"/api/v1/brizo/services/compute":{
|
||||
"post":{
|
||||
"consumes":[
|
||||
"application/json"
|
||||
],
|
||||
"description":"<br/><br/>If the publisher of the assets<br/>provide this service in the Service agreement related with the asset_did requested.<br/>",
|
||||
"parameters":[
|
||||
{
|
||||
"description":"Asset metadata.",
|
||||
"in":"body",
|
||||
"name":"body",
|
||||
"required":true,
|
||||
"schema":{
|
||||
"properties":{
|
||||
"algorithm_did":{
|
||||
"description":"Identifier of the algorithm to execute",
|
||||
"example":"0x0234242345",
|
||||
"type":"string"
|
||||
},
|
||||
"asset_did":{
|
||||
"description":"Identifier of the asset registered in ocean",
|
||||
"example":"0x0234242345",
|
||||
"type":"string"
|
||||
},
|
||||
"consumer_wallet":{
|
||||
"description":"Address of the wallet of the consumer of the asset. Ex. data-science...",
|
||||
"example":"0x0234242345",
|
||||
"type":"string"
|
||||
},
|
||||
"cpu":{
|
||||
"description":"Number of cpus to execute the algorithm.",
|
||||
"example":1,
|
||||
"type":"integer"
|
||||
},
|
||||
"docker_image":{
|
||||
"description":"Docker image where the algorithm is going to be executed. It must include all the libraries needs to run it.",
|
||||
"example":"python:3.6-alpine",
|
||||
"type":"string"
|
||||
},
|
||||
"memory":{
|
||||
"description":"Ammout of memory in Gb to run the algorithm",
|
||||
"example":1.5,
|
||||
"type":"number"
|
||||
}
|
||||
},
|
||||
"required":[
|
||||
"asset_did",
|
||||
"algorithm_did",
|
||||
"consumer_wallet"
|
||||
],
|
||||
"type":"object"
|
||||
}
|
||||
}
|
||||
],
|
||||
"responses":{
|
||||
|
||||
},
|
||||
"summary":"Allows to execute an algorithm inside in a docker instance in the cloud aquarius.",
|
||||
"tags":[
|
||||
"services"
|
||||
]
|
||||
}
|
||||
},
|
||||
"/api/v1/brizo/services/consume":{
|
||||
"get":{
|
||||
"consumes":[
|
||||
"application/json"
|
||||
],
|
||||
"description":"",
|
||||
"parameters":[
|
||||
{
|
||||
"description":"The consumer address.",
|
||||
"in":"query",
|
||||
"name":"consumerAddress",
|
||||
"required":true,
|
||||
"type":"string"
|
||||
},
|
||||
{
|
||||
"description":"The service agreement id.",
|
||||
"in":"query",
|
||||
"name":"serviceAgreementId",
|
||||
"required":true,
|
||||
"type":"string"
|
||||
},
|
||||
{
|
||||
"description":"This URL is only valid if BRIZO acts as a proxy. Consumer can't download using the URL if it's not through Brizo.",
|
||||
"in":"query",
|
||||
"name":"url",
|
||||
"required":true,
|
||||
"type":"string"
|
||||
}
|
||||
],
|
||||
"responses":{
|
||||
"200":{
|
||||
"description":"Download valid url."
|
||||
},
|
||||
"400":{
|
||||
"description":"One of the required attributes is missed."
|
||||
},
|
||||
"404":{
|
||||
"description":"Invalid asset data."
|
||||
},
|
||||
"500":{
|
||||
"description":"Error"
|
||||
}
|
||||
},
|
||||
"summary":"Allows download of asset data file.",
|
||||
"tags":[
|
||||
"services"
|
||||
]
|
||||
}
|
||||
}
|
||||
},
|
||||
"swagger":"2.0"
|
||||
}
|
@ -8,7 +8,7 @@
|
||||
- name: aquarius
|
||||
links:
|
||||
- name: API reference
|
||||
url: https://github.com/oceanprotocol/aquarius/blob/develop/docs/for_api_users/API.md
|
||||
url: /api/aquarius/
|
||||
|
||||
- name: brizo
|
||||
- name: pleuston
|
||||
|
@ -3,12 +3,17 @@
|
||||
- title: API References
|
||||
link: /api/introduction/
|
||||
|
||||
- group: squid-js
|
||||
items:
|
||||
- title: API reference
|
||||
link: /api/squid-js/
|
||||
# - group: squid-js
|
||||
# items:
|
||||
# - title: API reference
|
||||
# link: /api/squid-js/
|
||||
|
||||
- group: aquarius
|
||||
items:
|
||||
- title: API reference
|
||||
link: /api/aquarius/
|
||||
|
||||
- group: brizo
|
||||
items:
|
||||
- title: API reference
|
||||
link: /api/brizo/
|
||||
|
@ -1,6 +1,3 @@
|
||||
const fs = require('fs')
|
||||
const path = require('path')
|
||||
|
||||
require('dotenv').config()
|
||||
|
||||
if (!process.env.GITHUB_TOKEN) {
|
||||
@ -12,20 +9,6 @@ if (!process.env.GITHUB_TOKEN) {
|
||||
|
||||
const config = require('./config.js')
|
||||
|
||||
const fromJson = filePath => {
|
||||
return new Promise((resolve, reject) => {
|
||||
fs.readFile(filePath, 'utf8', (err, data) => {
|
||||
if (err) {
|
||||
reject(err)
|
||||
return
|
||||
}
|
||||
|
||||
const spec = JSON.parse(data)
|
||||
resolve(spec)
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
siteMetadata: {
|
||||
// spread all of our config values here
|
||||
@ -123,21 +106,6 @@ module.exports = {
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
resolve: 'gatsby-source-openapi-aggregate',
|
||||
options: {
|
||||
specs: [
|
||||
{
|
||||
name: 'aquarius',
|
||||
resolve: () =>
|
||||
fromJson(
|
||||
path.resolve(__dirname, './data/aquarius.json')
|
||||
)
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
'gatsby-transformer-json',
|
||||
'gatsby-transformer-yaml',
|
||||
{
|
||||
resolve: 'gatsby-plugin-sass',
|
||||
|
@ -40,7 +40,7 @@ exports.createPages = ({ graphql, actions }) => {
|
||||
resolve(
|
||||
graphql(
|
||||
`
|
||||
{
|
||||
query {
|
||||
allMarkdownRemark(
|
||||
filter: { fileAbsolutePath: { regex: "/content/" } }
|
||||
) {
|
||||
@ -74,17 +74,6 @@ exports.createPages = ({ graphql, actions }) => {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
allOpenApiSpec {
|
||||
edges {
|
||||
node {
|
||||
id
|
||||
name
|
||||
version
|
||||
title
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
`
|
||||
).then(result => {
|
||||
@ -134,24 +123,32 @@ exports.createPages = ({ graphql, actions }) => {
|
||||
})
|
||||
|
||||
// Create pages from swagger json files
|
||||
const swaggerSpecs = result.data.allOpenApiSpec.edges
|
||||
const apiSwaggerTemplate = path.resolve(
|
||||
'./src/templates/ApiSwagger.jsx'
|
||||
)
|
||||
console.log(swaggerSpecs)
|
||||
|
||||
swaggerSpecs.map(({ node }) => {
|
||||
const slug = `/api/${node.name}`
|
||||
console.log(slug)
|
||||
const aquariusSpecs = require('./data/aquarius.json')
|
||||
const aquariusSlug = '/api/aquarius/'
|
||||
|
||||
createPage({
|
||||
path: slug,
|
||||
component: apiSwaggerTemplate,
|
||||
context: {
|
||||
slug,
|
||||
id: node.id
|
||||
}
|
||||
})
|
||||
createPage({
|
||||
path: aquariusSlug,
|
||||
component: apiSwaggerTemplate,
|
||||
context: {
|
||||
slug: aquariusSlug,
|
||||
json: aquariusSpecs
|
||||
}
|
||||
})
|
||||
|
||||
const brizoSpecs = require('./data/brizo.json')
|
||||
const brizoSlug = '/api/brizo/'
|
||||
|
||||
createPage({
|
||||
path: brizoSlug,
|
||||
component: apiSwaggerTemplate,
|
||||
context: {
|
||||
slug: brizoSlug,
|
||||
json: brizoSpecs
|
||||
}
|
||||
})
|
||||
|
||||
resolve()
|
||||
|
@ -47,8 +47,6 @@
|
||||
"gatsby-remark-smartypants": "^2.0.6",
|
||||
"gatsby-source-filesystem": "^2.0.9",
|
||||
"gatsby-source-graphql": "^2.0.6",
|
||||
"gatsby-source-openapi-aggregate": "^0.1.8",
|
||||
"gatsby-transformer-json": "^2.1.5",
|
||||
"gatsby-transformer-remark": "^2.1.12",
|
||||
"gatsby-transformer-sharp": "^2.1.8",
|
||||
"gatsby-transformer-yaml": "^2.1.5",
|
||||
|
@ -9,6 +9,7 @@ import Sidebar from '../components/Sidebar'
|
||||
import DocHeader from '../components/DocHeader'
|
||||
import SEO from '../components/Seo'
|
||||
import stylesDoc from './Doc.module.scss'
|
||||
import styles from './ApiSwagger.module.scss'
|
||||
|
||||
export default class ApiSwaggerTemplate extends Component {
|
||||
static propTypes = {
|
||||
@ -18,11 +19,9 @@ export default class ApiSwaggerTemplate extends Component {
|
||||
}
|
||||
|
||||
render() {
|
||||
const { location } = this.props
|
||||
const api = this.props.data.openApiSpec
|
||||
const paths = api.childrenOpenApiSpecPath
|
||||
const { location, data, pageContext } = this.props
|
||||
const sections = this.props.data.allSectionsYaml.edges
|
||||
const { title, description } = api
|
||||
const { title, description } = pageContext.json.info
|
||||
|
||||
// output section title as defined in sections.yml
|
||||
const sectionTitle = sections.map(({ node }) => {
|
||||
@ -32,6 +31,8 @@ export default class ApiSwaggerTemplate extends Component {
|
||||
}
|
||||
})
|
||||
|
||||
console.log(data)
|
||||
|
||||
return (
|
||||
<>
|
||||
<Helmet>
|
||||
@ -41,7 +42,7 @@ export default class ApiSwaggerTemplate extends Component {
|
||||
<SEO
|
||||
title={title}
|
||||
description={description}
|
||||
slug={this.props.pageContext.slug}
|
||||
slug={pageContext.slug}
|
||||
article
|
||||
/>
|
||||
|
||||
@ -60,9 +61,14 @@ export default class ApiSwaggerTemplate extends Component {
|
||||
<article className={stylesDoc.main}>
|
||||
<DocHeader title={title} />
|
||||
|
||||
{Object.keys(paths).map(path => (
|
||||
<div key={path}>{path}</div>
|
||||
))}
|
||||
{Object.keys(pageContext.json.paths).map(
|
||||
path => (
|
||||
<div key={path} className={styles.path}>
|
||||
<h2>{path}</h2>
|
||||
{path.get && <h3>GET</h3>}
|
||||
</div>
|
||||
)
|
||||
)}
|
||||
</article>
|
||||
</main>
|
||||
</Content>
|
||||
@ -73,30 +79,11 @@ export default class ApiSwaggerTemplate extends Component {
|
||||
}
|
||||
|
||||
export const pageQuery = graphql`
|
||||
query ApiQuery($id: String!) {
|
||||
openApiSpec(id: { eq: $id }) {
|
||||
version
|
||||
title
|
||||
description
|
||||
childrenOpenApiSpecPath {
|
||||
name
|
||||
verb
|
||||
summary
|
||||
description
|
||||
parameters {
|
||||
name
|
||||
in
|
||||
description
|
||||
required
|
||||
type
|
||||
}
|
||||
tag
|
||||
childrenOpenApiSpecResponse {
|
||||
id
|
||||
statusCode
|
||||
description
|
||||
}
|
||||
}
|
||||
query($slug: String!) {
|
||||
markdownRemark(fields: { slug: { eq: $slug } }) {
|
||||
id
|
||||
tableOfContents
|
||||
html
|
||||
}
|
||||
|
||||
allSectionsYaml {
|
||||
|
0
src/templates/ApiSwagger.module.scss
Normal file
0
src/templates/ApiSwagger.module.scss
Normal file
Loading…
Reference in New Issue
Block a user