diff --git a/README.md b/README.md
index 0be055d5..48946997 100644
--- a/README.md
+++ b/README.md
@@ -2,7 +2,7 @@
docs
-> 🐍 Ocean Protocol's official documentation.
+> 🐍 Ocean Protocol's official documentation. https://docs.oceanprotocol.com
[](https://travis-ci.com/oceanprotocol/docs)
[](https://github.com/prettier/prettier)
@@ -27,6 +27,9 @@
- [Repositories](#repositories)
- [Add Links to a Repository](#add-links-to-a-repository)
- [Release Versions](#release-versions)
+ - [API & Library References](#api--library-references)
+ - [Swagger specs](#swagger-specs)
+ - [TypeDoc specs](#typedoc-specs)
- [Development](#development)
- [Using npm](#using-npm)
- [Using Docker](#using-docker)
@@ -186,6 +189,33 @@ The GitHub link is automatically added for every repository and will always be d
The displayed version number is based on the tag name of the latest release for a given repository. That means only GitHub releases will trigger a version number update, creating a new Git tag alone is not sufficient.
+### API & Library References
+
+You can add more Markdown documents under `/content/references/`, link to them from the [`/data/sidebars/references.yml`](./data/sidebars/references.yml), and they will appear just like in all the other sections.
+
+But the actual reference pages in this section are constructed from data files during site build (as defined in [`gatsby-node.js`](./gatsby-node.js)) with their own little rules. Generally, you can't edit their content within this site, you have to go to the respective repository and edit the documentation strings living with the source code.
+
+The sidebar for those generated reference pages will automatically switch to include the table of contents of those pages so no need to define additional links in the [`/data/sidebars/references.yml`](./data/sidebars/references.yml) file for them.
+
+#### Swagger specs
+
+Reference pages based on Swagger specs are sourced from a Swagger spec `json` file, at the moment they simply live as manual copies under `/data/`:
+
+- [`aquarius.json`](./data/aquarius.json)
+- [`brizo.json`](./data/brizo.json)
+
+There's no automation setup around updating those files so [until this is setup](https://github.com/oceanprotocol/docs/issues/74), they need to be manually updated with copy & paste, like they did in the middle ages. You can copy them from a running instance of Aquarius or Brizo which will expose those spec files, e.g. under `localhost:5000/spec` for Aquarius and `localhost:8030/spec` for Brizo.
+
+For more information about stylistic issues, take a look at the section in the test page:
+
+- [Swagger spec references](https://docs.oceanprotocol.com/test#swagger-spec-references)
+
+#### TypeDoc specs
+
+Reference pages based on generated `json` file from TypeDoc.
+
+_Coming soon... see [#45](https://github.com/oceanprotocol/docs/issues/45)_
+
## Development
The site is a React app built with [Gatsby](https://www.gatsbyjs.org).
@@ -198,8 +228,8 @@ This Git repo has [Git submodules](https://git-scm.com/book/en/v2/Git-Tools-Subm
git clone --recurse-submodules git@github.com:oceanprotocol/docs.git
```
-1. Don't edit anything in the submodules (i.e. in `external/`). Instead, edit it over in the other Git repository and merge your changes over there.
-1. Get all the submodules up-to-date using:
+2. Don't edit anything in the submodules (i.e. in `external/`). Instead, edit it over in the other Git repository and merge your changes over there.
+3. Get all the submodules up-to-date using:
```bash
git submodule update --remote --recursive
@@ -207,7 +237,7 @@ This Git repo has [Git submodules](https://git-scm.com/book/en/v2/Git-Tools-Subm
That will get each submodule up-to-date with the HEAD commit of some branch in a remote repository. Which branch? That's set in the `.gitmodules` file. You can check the current commit hashes of all the submodules using `git submodule status`
-1. Before doing any `git checkout ...` or other normal Git operations, do this:
+4. Before doing any `git checkout ...` or other normal Git operations, do this:
```bash
git config --global submodule.recurse true
diff --git a/config.js b/config.js
index 61d93973..80b31007 100644
--- a/config.js
+++ b/config.js
@@ -31,6 +31,10 @@ module.exports = {
{
from: '/tutorials/',
to: '/tutorials/introduction/'
+ },
+ {
+ from: '/references/',
+ to: '/references/introduction/'
}
]
}
diff --git a/content/references/introduction.md b/content/references/introduction.md
new file mode 100644
index 00000000..2d09fe5c
--- /dev/null
+++ b/content/references/introduction.md
@@ -0,0 +1,19 @@
+---
+title: API & Library References
+description: All the references for Ocean Protocol components.
+---
+
+**Heads Up! This reference section is in heavy development and updated as we integrate data from various code reference tools into this site.**
+
+The following components expose a consumable REST API which are documented on this site:
+
+
+
+
+Those are sourced from their respective Swagger specs. On this site you can't execute the documented API calls yet. If you need this, you can run a component's local Swagger UI as outlined in the repository instructions on GitHub.
+
+References of all the functions and methods used in our libraries are not yet integrated here. For now, have a look at the respective repos for more infos:
+
+
+
+
diff --git a/content/test.md b/content/test.md
index 78b1c6c5..728e8307 100644
--- a/content/test.md
+++ b/content/test.md
@@ -366,3 +366,14 @@ GITHUB-EMBED https://github.com/oceanprotocol/squid-js/blob/develop/src/keeper/W
Resulting in:
GITHUB-EMBED https://github.com/oceanprotocol/squid-js/blob/develop/src/keeper/Web3Provider.ts js GITHUB-EMBED
+
+## Swagger spec references
+
+Many Swagger fields like the description (`info.description`) are rendered through Markdown so you can write actual Markdown in those fields.
+
+- [Aquarius API reference](/references/aquarius/)
+- [Brizo API reference](/references/brizo/)
+
+For a complete overview of everything supported by Swagger and implemented in this site, take a look at the hidden Pet Store example:
+
+- [Pet Store Example](/references/pet-store/)
diff --git a/data/aquarius.json b/data/aquarius.json
new file mode 100644
index 00000000..d0f14b21
--- /dev/null
+++ b/data/aquarius.json
@@ -0,0 +1,532 @@
+{
+ "basePath":"/api/v1/aquarius",
+ "definitions":{
+
+ },
+ "host":"myfancyaquarius.com",
+ "info":{
+ "description":"Aquarius provides an off-chain database store for metadata about data assets. When running with our Docker images, it is exposed under `http://localhost:5000`.",
+ "title":"Aquarius",
+ "version":"0.1.4"
+ },
+ "paths":{
+ "/api/v1/aquarius/assets":{
+ "get":{
+ "description":"",
+ "responses":{
+ "200":{
+ "description":"successful action"
+ }
+ },
+ "summary":"Get all asset IDs.",
+ "tags":[
+ "ddo"
+ ]
+ }
+ },
+ "/api/v1/aquarius/assets/ddo":{
+ "get":{
+ "description":"",
+ "responses":{
+ "200":{
+ "description":"successful action"
+ }
+ },
+ "summary":"Get DDO of all assets.",
+ "tags":[
+ "ddo"
+ ]
+ },
+ "post":{
+ "consumes":[
+ "application/json"
+ ],
+ "description":"",
+ "parameters":[
+ {
+ "description":"DDO of the asset.",
+ "in":"body",
+ "name":"body",
+ "required":true,
+ "schema":{
+ "properties":{
+ "@context":{
+ "description":null,
+ "example":"https://w3id.org/future-method/v1",
+ "type":"string"
+ },
+ "authentication":{
+ "description":"List of authentication mechanisms.",
+ "example":[
+ {
+ "type":"RsaSignatureAuthentication2018"
+ },
+ {
+ "publicKey":"did:op:123456789abcdefghi#keys-1"
+ }
+ ],
+ "type":"array"
+ },
+ "id":{
+ "description":"ID of the asset.",
+ "example":"did:op:123456789abcdefghi",
+ "type":"string"
+ },
+ "publicKey":{
+ "description":"List of public keys.",
+ "example":[
+ {
+ "id":"did:op:123456789abcdefghi#keys-1"
+ },
+ {
+ "type":"Ed25519VerificationKey2018"
+ },
+ {
+ "owner":"did:op:123456789abcdefghi"
+ },
+ {
+ "publicKeyBase58":"H3C2AVvLMv6gmMNam3uVAjZpfkcJCwDwnZn6z3wXmqPV"
+ }
+ ],
+ "type":"array"
+ },
+ "service":{
+ "description":"List of services.",
+ "example":[
+ {
+ "serviceEndpoint":"http://mybrizo.org/api/v1/brizo/services/consume?pubKey=${pubKey}&serviceId={serviceId}&url={url}",
+ "type":"Consume"
+ },
+ {
+ "serviceEndpoint":"http://mybrizo.org/api/v1/brizo/services/compute?pubKey=${pubKey}&serviceId={serviceId}&algo={algo}&container={container}",
+ "type":"Compute"
+ },
+ {
+ "metadata":{
+ "additionalInformation":{
+ "structuredMarkup":[
+ {
+ "mediaType":"application/ld+json",
+ "uri":"http://skos.um.es/unescothes/C01194/jsonld"
+ },
+ {
+ "mediaType":"text/turtle",
+ "uri":"http://skos.um.es/unescothes/C01194/turtle"
+ }
+ ],
+ "updateFrecuency":"yearly"
+ },
+ "base":{
+ "author":"Met Office",
+ "compression":"zip",
+ "contentType":"text/csv",
+ "contentUrls":[
+ "https://testocnfiles.blob.core.windows.net/testfiles/testzkp.zip"
+ ],
+ "copyrightHolder":"Met Office",
+ "dateCreated":"2012-10-10T17:00:000Z",
+ "description":"Weather information of UK including temperature and humidity",
+ "encoding":"UTF-8",
+ "inLanguage":"en",
+ "license":"CC-BY",
+ "links":[
+ {
+ "sample1":"http://data.ceda.ac.uk/badc/ukcp09/data/gridded-land-obs/gridded-land-obs-daily/"
+ },
+ {
+ "sample2":"http://data.ceda.ac.uk/badc/ukcp09/data/gridded-land-obs/gridded-land-obs-averages-25km/"
+ },
+ {
+ "fieldsDescription":"http://data.ceda.ac.uk/badc/ukcp09/"
+ }
+ ],
+ "name":"UK Weather information 2011",
+ "price":10,
+ "size":"3.1gb",
+ "tags":"weather, uk, 2011, temperature, humidity",
+ "type":"dataset",
+ "workExample":"423432fsd,51.509865,-0.118092,2011-01-01T10:55:11+00:00,7.2,68"
+ },
+ "curation":{
+ "numVotes":123,
+ "rating":0.93,
+ "schema":"Binary Votting"
+ }
+ },
+ "serviceEndpoint":"http://myaquarius.org/api/v1/provider/assets/metadata/{did}",
+ "type":"Metadata"
+ }
+ ],
+ "type":"array"
+ }
+ },
+ "required":[
+ "@context",
+ "id",
+ "publicKey",
+ "authentication",
+ "service"
+ ],
+ "type":"object"
+ }
+ }
+ ],
+ "responses":{
+ "201":{
+ "description":"Asset successfully registered."
+ },
+ "400":{
+ "description":"One of the required attributes is missing."
+ },
+ "404":{
+ "description":"Invalid asset data."
+ },
+ "500":{
+ "description":"Error"
+ }
+ },
+ "summary":"Register DDO of a new asset",
+ "tags":[
+ "ddo"
+ ]
+ }
+ },
+ "/api/v1/aquarius/assets/ddo/query":{
+ "get":{
+ "description":"",
+ "parameters":[
+ {
+ "description":"ID of the asset.",
+ "in":"query",
+ "name":"text",
+ "required":true,
+ "type":"string"
+ },
+ {
+ "description":"Key or list of keys to sort the result",
+ "example":{
+ "value":1
+ },
+ "in":"query",
+ "name":"sort",
+ "type":"object"
+ },
+ {
+ "description":"Number of records per page",
+ "example":100,
+ "in":"query",
+ "name":"offset",
+ "type":"int"
+ },
+ {
+ "description":"Page showed",
+ "example":0,
+ "in":"query",
+ "name":"page",
+ "type":"int"
+ }
+ ],
+ "responses":{
+ "200":{
+ "description":"successful action"
+ }
+ },
+ "summary":"Get a list of DDOs that match with the given text.",
+ "tags":[
+ "ddo"
+ ]
+ },
+ "post":{
+ "consumes":[
+ "application/json"
+ ],
+ "description":"",
+ "parameters":[
+ {
+ "description":"Asset metadata.",
+ "in":"body",
+ "name":"body",
+ "required":true,
+ "schema":{
+ "properties":{
+ "offset":{
+ "description":"Number of records per page",
+ "example":100,
+ "type":"int"
+ },
+ "page":{
+ "description":"Page showed",
+ "example":0,
+ "type":"int"
+ },
+ "query":{
+ "description":"Query to realize",
+ "example":{
+ "value":1
+ },
+ "type":"string"
+ },
+ "sort":{
+ "description":"Key or list of keys to sort the result",
+ "example":{
+ "value":1
+ },
+ "type":"object"
+ }
+ },
+ "type":"object"
+ }
+ }
+ ],
+ "responses":{
+ "200":{
+ "description":"successful action"
+ }
+ },
+ "summary":"Get a list of DDOs that match with the executed query.",
+ "tags":[
+ "ddo"
+ ]
+ }
+ },
+ "/api/v1/aquarius/assets/ddo/{did}":{
+ "put":{
+ "consumes":[
+ "application/json"
+ ],
+ "description":"",
+ "parameters":[
+ {
+ "description":"DDO of the asset.",
+ "in":"body",
+ "name":"body",
+ "required":true,
+ "schema":{
+ "properties":{
+ "@context":{
+ "description":null,
+ "example":"https://w3id.org/future-method/v1",
+ "type":"string"
+ },
+ "authentication":{
+ "description":"List of authentication mechanisms.",
+ "example":[
+ {
+ "type":"RsaSignatureAuthentication2018"
+ },
+ {
+ "publicKey":"did:op:123456789abcdefghi#keys-1"
+ }
+ ],
+ "type":"array"
+ },
+ "id":{
+ "description":"ID of the asset.",
+ "example":"did:op:123456789abcdefghi",
+ "type":"string"
+ },
+ "publicKey":{
+ "description":"List of public keys.",
+ "example":[
+ {
+ "id":"did:op:123456789abcdefghi#keys-1"
+ },
+ {
+ "type":"Ed25519VerificationKey2018"
+ },
+ {
+ "owner":"did:op:123456789abcdefghi"
+ },
+ {
+ "publicKeyBase58":"H3C2AVvLMv6gmMNam3uVAjZpfkcJCwDwnZn6z3wXmqPV"
+ }
+ ],
+ "type":"array"
+ },
+ "service":{
+ "description":"List of services.",
+ "example":[
+ {
+ "serviceEndpoint":"http://mybrizo.org/api/v1/brizo/services/consume?pubKey=${pubKey}&serviceId={serviceId}&url={url}",
+ "type":"Consume"
+ },
+ {
+ "serviceEndpoint":"http://mybrizo.org/api/v1/brizo/services/compute?pubKey=${pubKey}&serviceId={serviceId}&algo={algo}&container={container}",
+ "type":"Compute"
+ },
+ {
+ "metadata":{
+ "additionalInformation":{
+ "structuredMarkup":[
+ {
+ "mediaType":"application/ld+json",
+ "uri":"http://skos.um.es/unescothes/C01194/jsonld"
+ },
+ {
+ "mediaType":"text/turtle",
+ "uri":"http://skos.um.es/unescothes/C01194/turtle"
+ }
+ ],
+ "updateFrecuency":"yearly"
+ },
+ "base":{
+ "author":"Met Office",
+ "compression":"zip",
+ "contentType":"text/csv",
+ "contentUrls":[
+ "https://testocnfiles.blob.core.windows.net/testfiles/testzkp.zip"
+ ],
+ "copyrightHolder":"Met Office",
+ "dateCreated":"2012-10-10T17:00:000Z",
+ "description":"Weather information of UK including temperature and humidity",
+ "encoding":"UTF-8",
+ "inLanguage":"en",
+ "license":"CC-BY",
+ "links":[
+ {
+ "name":"Sample of Asset Data",
+ "type":"sample",
+ "url":"https://foo.com/sample.csv"
+ },
+ {
+ "AssetID":"4d517500da0acb0d65a716f61330969334630363ce4a6a9d39691026ac7908ea",
+ "name":"Data Format Definition",
+ "type":"format"
+ }
+ ],
+ "name":"UK Weather information 2011",
+ "price":10,
+ "size":"3.1gb",
+ "tags":"weather, uk, 2011, temperature, humidity",
+ "type":"dataset",
+ "workExample":"423432fsd,51.509865,-0.118092,2011-01-01T10:55:11+00:00,7.2,68"
+ },
+ "curation":{
+ "numVotes":123,
+ "rating":0.93,
+ "schema":"Binary Voting"
+ }
+ },
+ "serviceEndpoint":"http://myaquarius.org/api/v1/aquarius/assets/metadata/{did}",
+ "type":"Metadata"
+ }
+ ],
+ "type":"array"
+ }
+ },
+ "required":[
+ "@context",
+ "id",
+ "publicKey",
+ "authentication",
+ "service"
+ ],
+ "type":"object"
+ }
+ }
+ ],
+ "responses":{
+ "200":{
+ "description":"Asset successfully updated."
+ },
+ "201":{
+ "description":"Asset successfully registered."
+ },
+ "400":{
+ "description":"One of the required attributes is missing."
+ },
+ "404":{
+ "description":"Invalid asset data."
+ },
+ "500":{
+ "description":"Error"
+ }
+ },
+ "summary":"Update DDO of an existing asset",
+ "tags":[
+ "ddo"
+ ]
+ }
+ },
+ "/api/v1/aquarius/assets/ddo/{id}":{
+ "delete":{
+ "description":"",
+ "parameters":[
+ {
+ "description":"ID of the asset.",
+ "in":"path",
+ "name":"id",
+ "required":true,
+ "type":"string"
+ }
+ ],
+ "responses":{
+ "200":{
+ "description":"successfully deleted"
+ },
+ "404":{
+ "description":"This asset ID is not in OceanDB"
+ },
+ "500":{
+ "description":"Error"
+ }
+ },
+ "summary":"Retire metadata of an asset",
+ "tags":[
+ "ddo"
+ ]
+ },
+ "get":{
+ "description":"",
+ "parameters":[
+ {
+ "description":"ID of the asset.",
+ "in":"path",
+ "name":"id",
+ "required":true,
+ "type":"string"
+ }
+ ],
+ "responses":{
+ "200":{
+ "description":"successful operation"
+ },
+ "404":{
+ "description":"This asset ID is not in OceanDB"
+ }
+ },
+ "summary":"Get DDO of a particular asset.",
+ "tags":[
+ "ddo"
+ ]
+ }
+ },
+ "/api/v1/aquarius/assets/metadata/{id}":{
+ "get":{
+ "description":"",
+ "parameters":[
+ {
+ "description":"ID of the asset.",
+ "in":"path",
+ "name":"id",
+ "required":true,
+ "type":"string"
+ }
+ ],
+ "responses":{
+ "200":{
+ "description":"successful operation."
+ },
+ "404":{
+ "description":"This asset ID is not in OceanDB."
+ }
+ },
+ "summary":"Get metadata of a particular asset",
+ "tags":[
+ "metadata"
+ ]
+ }
+ }
+ },
+ "swagger":"2.0"
+}
diff --git a/data/brizo.json b/data/brizo.json
new file mode 100644
index 00000000..bb43ee47
--- /dev/null
+++ b/data/brizo.json
@@ -0,0 +1,200 @@
+{
+ "basePath":"/api/v1/brizo",
+ "definitions":{
+
+ },
+ "host":"myfancybrizo.com",
+ "info":{
+ "description":"Brizo is the technical component executed by Publishers allowing them to provide extended data services. When running with our Docker images, it is exposed under `http://localhost:8030`.",
+ "title":"Brizo",
+ "version":"0.1.2"
+ },
+ "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 successfully initialized."
+ },
+ "400":{
+ "description":"One of the required attributes is missing."
+ },
+ "404":{
+ "description":"Invalid signature."
+ },
+ "500":{
+ "description":"Error"
+ }
+ },
+ "summary":"Initialize the SLA between the publisher and the consumer.",
+ "tags":[
+ "services"
+ ]
+ }
+ },
+ "/api/v1/brizo/services/compute":{
+ "post":{
+ "consumes":[
+ "application/json"
+ ],
+ "description":"",
+ "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 asset consumer. 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. Docker image must include all the libraries needed 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 a Docker instance in the cloud. Requires the publisher of the assets to provide this service in the service agreement related with the requested `asset_did`.",
+ "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 ID of the service agreement.",
+ "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":{
+ "302":{
+ "description":"Redirect to valid asset url."
+ },
+ "400":{
+ "description":"One of the required attributes is missing."
+ },
+ "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..76b40b6b 100644
--- a/data/repositories.yml
+++ b/data/repositories.yml
@@ -8,9 +8,13 @@
- name: aquarius
links:
- name: API reference
- url: https://github.com/oceanprotocol/aquarius/blob/develop/docs/for_api_users/API.md
+ url: /references/aquarius/
- name: brizo
+ links:
+ - name: API reference
+ url: /references/brizo/
+
- name: pleuston
- group: Libraries
diff --git a/data/sections.yml b/data/sections.yml
index 4486dfc2..4593830f 100644
--- a/data/sections.yml
+++ b/data/sections.yml
@@ -13,8 +13,7 @@
link: /tutorials/introduction/
color: orange
-- title: API References
- #description: Get the API references for all relevant components.
- description: Coming soon.
- #link: /api/introduction/
+- title: API & Library References
+ description: Get the references for REST APIs and library methods for all relevant components.
+ link: /references/introduction/
color: green
diff --git a/data/sidebars/references.yml b/data/sidebars/references.yml
new file mode 100644
index 00000000..e153745c
--- /dev/null
+++ b/data/sidebars/references.yml
@@ -0,0 +1,19 @@
+- group: Overview
+ items:
+ - title: API References
+ link: /references/introduction/
+
+# - group: squid-js
+# items:
+# - title: API reference
+# link: /api/squid-js/
+
+- group: aquarius
+ items:
+ - title: API reference
+ link: /references/aquarius/
+
+- group: brizo
+ items:
+ - title: API reference
+ link: /references/brizo/
diff --git a/gatsby-config.js b/gatsby-config.js
index 05268c46..ee991cd0 100755
--- a/gatsby-config.js
+++ b/gatsby-config.js
@@ -131,7 +131,7 @@ module.exports = {
{
resolve: 'gatsby-plugin-sitemap',
options: {
- exclude: ['/test/']
+ exclude: ['/test/', '/references/petstore/']
}
},
{
diff --git a/gatsby-node.js b/gatsby-node.js
index 875525fd..7850bee1 100755
--- a/gatsby-node.js
+++ b/gatsby-node.js
@@ -2,6 +2,7 @@
const path = require('path')
const { createFilePath } = require('gatsby-source-filesystem')
+const Swagger = require('swagger-client')
const { redirects } = require('./config')
exports.onCreateNode = ({ node, getNode, actions }) => {
@@ -36,6 +37,26 @@ exports.onCreateNode = ({ node, getNode, actions }) => {
}
}
+// https://github.com/swagger-api/swagger-js
+const getSpec = async () => {
+ const spec = await Swagger(
+ 'http://petstore.swagger.io/v2/swagger.json'
+ ).then(client => {
+ return client.spec // The resolved spec
+
+ // client.originalSpec // In case you need it
+ // client.errors // Any resolver errors
+
+ // Tags interface
+ // client.apis.pet.addPet({id: 1, name: "bobby"}).then(...)
+
+ // TryItOut Executor, with the `spec` already provided
+ // client.execute({operationId: 'addPet', parameters: {id: 1, name: "bobby") }).then(...)
+ })
+
+ return spec
+}
+
exports.createPages = ({ graphql, actions }) => {
const { createPage, createRedirect } = actions
@@ -43,7 +64,7 @@ exports.createPages = ({ graphql, actions }) => {
resolve(
graphql(
`
- {
+ query {
allMarkdownRemark(
filter: { fileAbsolutePath: { regex: "/content/" } }
) {
@@ -79,9 +100,8 @@ exports.createPages = ({ graphql, actions }) => {
}
}
`
- ).then(result => {
+ ).then(async result => {
if (result.errors) {
- /* eslint-disable-next-line no-console */
console.log(result.errors)
reject(result.errors)
}
@@ -89,7 +109,9 @@ exports.createPages = ({ graphql, actions }) => {
const docTemplate = path.resolve('./src/templates/Doc.jsx')
const posts = result.data.allMarkdownRemark.edges
+ //
// Create Doc pages
+ //
posts.forEach(post => {
createPage({
path: `${post.node.fields.slug}`,
@@ -101,7 +123,9 @@ exports.createPages = ({ graphql, actions }) => {
})
})
+ //
// Create pages from dev-ocean contents
+ //
const postsDevOcean = result.data.devOceanDocs.edges
postsDevOcean
@@ -125,6 +149,54 @@ exports.createPages = ({ graphql, actions }) => {
})
})
+ //
+ // Create pages from swagger json files
+ //
+ const apiSwaggerTemplate = path.resolve(
+ './src/templates/ApiSwagger.jsx'
+ )
+
+ const petStoreSlug = '/references/petstore/'
+
+ try {
+ const spec = await getSpec()
+
+ createPage({
+ path: petStoreSlug,
+ component: apiSwaggerTemplate,
+ context: {
+ slug: petStoreSlug,
+ api: spec
+ }
+ })
+ } catch (error) {
+ console.log(error)
+ }
+
+ const aquariusSpecs = require('./data/aquarius.json')
+ const aquariusSlug = '/references/aquarius/'
+
+ createPage({
+ path: aquariusSlug,
+ component: apiSwaggerTemplate,
+ context: {
+ slug: aquariusSlug,
+ api: aquariusSpecs
+ }
+ })
+
+ const brizoSpecs = require('./data/brizo.json')
+ const brizoSlug = '/references/brizo/'
+
+ createPage({
+ path: brizoSlug,
+ component: apiSwaggerTemplate,
+ context: {
+ slug: brizoSlug,
+ api: brizoSpecs
+ }
+ })
+
//
// create redirects
//
diff --git a/package.json b/package.json
index b12b0f9a..d22abd6d 100644
--- a/package.json
+++ b/package.json
@@ -59,7 +59,9 @@
"react-helmet": "^5.2.0",
"rehype-react": "^3.1.0",
"remark": "^10.0.1",
- "remark-react": "^5.0.0"
+ "remark-react": "^5.0.0",
+ "slugify": "^1.3.3",
+ "swagger-client": "^3.8.22"
},
"devDependencies": {
"@svgr/webpack": "^4.1.0",
diff --git a/src/components/DocFooter.jsx b/src/components/DocFooter.jsx
index fe2eedf3..1e5177a8 100644
--- a/src/components/DocFooter.jsx
+++ b/src/components/DocFooter.jsx
@@ -4,31 +4,31 @@ import { ReactComponent as Pencil } from '../images/pencil.svg'
import styles from './DocFooter.module.scss'
import { githubContentPath, githubDevOceanPath } from '../../config'
-const DocFooter = ({ post }) => {
- const { sourceInstanceName } = post.parent
-
+const DocFooter = ({ post, url, externalName }) => {
let path
- let externalRepoName
- switch (sourceInstanceName) {
- case 'dev-ocean':
- path = githubDevOceanPath
- externalRepoName = sourceInstanceName
- break
- default:
- path = githubContentPath
+ if (post) {
+ const { sourceInstanceName } = post.parent
+
+ switch (sourceInstanceName) {
+ case 'dev-ocean':
+ path = githubDevOceanPath
+ externalName = sourceInstanceName
+ break
+ default:
+ path = githubContentPath
+ }
+
+ url = `${path}/${post.parent.relativePath}`
}
return (