diff --git a/content/api/squid-js.md b/content/api/squid-js.md deleted file mode 100644 index 881899b2..00000000 --- a/content/api/squid-js.md +++ /dev/null @@ -1,12 +0,0 @@ ---- -title: squid-js -description: API reference for squid-js. ---- - -Hello Squid. - -## Asset - -### getId - -### purchase diff --git a/data/aquarius.json b/data/aquarius.json index 05cbefbc..e2cae9d6 100644 --- a/data/aquarius.json +++ b/data/aquarius.json @@ -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" diff --git a/data/brizo.json b/data/brizo.json new file mode 100644 index 00000000..f25073a6 --- /dev/null +++ b/data/brizo.json @@ -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":"

If the publisher of the assets
provide this service in the Service agreement related with the asset_did requested.
", + "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" +} diff --git a/data/repositories.yml b/data/repositories.yml index 0bbd7d5a..843a4c86 100644 --- a/data/repositories.yml +++ b/data/repositories.yml @@ -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 diff --git a/data/sidebars/api.yml b/data/sidebars/api.yml index 8ce3a95e..705f6229 100644 --- a/data/sidebars/api.yml +++ b/data/sidebars/api.yml @@ -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/ diff --git a/gatsby-config.js b/gatsby-config.js index 755a5d6b..6464be02 100755 --- a/gatsby-config.js +++ b/gatsby-config.js @@ -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', diff --git a/gatsby-node.js b/gatsby-node.js index 58aabfa4..38f75c42 100755 --- a/gatsby-node.js +++ b/gatsby-node.js @@ -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() diff --git a/package.json b/package.json index 7b677569..7c410eb9 100644 --- a/package.json +++ b/package.json @@ -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", diff --git a/src/templates/ApiSwagger.jsx b/src/templates/ApiSwagger.jsx index f5ef5123..7527c9f3 100644 --- a/src/templates/ApiSwagger.jsx +++ b/src/templates/ApiSwagger.jsx @@ -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 ( <> @@ -41,7 +42,7 @@ export default class ApiSwaggerTemplate extends Component { @@ -60,9 +61,14 @@ export default class ApiSwaggerTemplate extends Component {
- {Object.keys(paths).map(path => ( -
{path}
- ))} + {Object.keys(pageContext.json.paths).map( + path => ( +
+

{path}

+ {path.get &&

GET

} +
+ ) + )}
@@ -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 { diff --git a/src/templates/ApiSwagger.module.scss b/src/templates/ApiSwagger.module.scss new file mode 100644 index 00000000..e69de29b