mirror of
https://github.com/oceanprotocol/docs.git
synced 2024-11-26 19:49:26 +01:00
Feature: Update swagger spec urls (#719)
This commit is contained in:
parent
81d00c61ac
commit
a9bd6607f3
10
config.js
10
config.js
@ -68,5 +68,15 @@ module.exports = {
|
|||||||
from: '/concepts/connect-to-networks/',
|
from: '/concepts/connect-to-networks/',
|
||||||
to: '/concepts/networks/'
|
to: '/concepts/networks/'
|
||||||
}
|
}
|
||||||
|
],
|
||||||
|
swaggerComponents: [
|
||||||
|
{
|
||||||
|
name: 'aquarius',
|
||||||
|
url: 'https://aquarius.oceanprotocol.com/spec'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'provider',
|
||||||
|
url: 'https://provider.mainnet.oceanprotocol.com/spec'
|
||||||
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
const path = require('path')
|
const path = require('path')
|
||||||
const { createFilePath } = require('gatsby-source-filesystem')
|
const { createFilePath } = require('gatsby-source-filesystem')
|
||||||
const Swagger = require('swagger-client')
|
const Swagger = require('swagger-client')
|
||||||
const { redirects } = require('./config')
|
const { redirects, swaggerComponents } = require('./config')
|
||||||
|
|
||||||
exports.onCreateNode = ({ node, getNode, actions }) => {
|
exports.onCreateNode = ({ node, getNode, actions }) => {
|
||||||
const { createNodeField } = actions
|
const { createNodeField } = actions
|
||||||
@ -213,11 +213,9 @@ const createTypeDocPage = async (createPage, name, downloadUrl) => {
|
|||||||
// Create pages from swagger json files
|
// Create pages from swagger json files
|
||||||
//
|
//
|
||||||
// https://github.com/swagger-api/swagger-js
|
// https://github.com/swagger-api/swagger-js
|
||||||
const fetchSwaggerSpec = async (component) => {
|
const fetchSwaggerSpec = async (url) => {
|
||||||
try {
|
try {
|
||||||
const client = await Swagger(
|
const client = await Swagger(url)
|
||||||
`https://${component}.mainnet.oceanprotocol.com/spec`
|
|
||||||
)
|
|
||||||
return client.spec // The resolved spec
|
return client.spec // The resolved spec
|
||||||
|
|
||||||
// client.originalSpec // In case you need it
|
// client.originalSpec // In case you need it
|
||||||
@ -234,21 +232,20 @@ const fetchSwaggerSpec = async (component) => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const createSwaggerPages = async (createPage) => {
|
const createSwaggerPages = async (createPage) => {
|
||||||
const swaggerComponents = ['aquarius', 'provider']
|
|
||||||
const apiSwaggerTemplate = path.resolve('./src/templates/Swagger/index.jsx')
|
const apiSwaggerTemplate = path.resolve('./src/templates/Swagger/index.jsx')
|
||||||
|
|
||||||
const getSlug = (name) => `/references/${name}/`
|
const getSlug = (name) => `/references/${name}/`
|
||||||
|
|
||||||
for (const component of swaggerComponents) {
|
for (const component of swaggerComponents) {
|
||||||
const slug = getSlug(component)
|
const slug = getSlug(component.name)
|
||||||
|
|
||||||
createPage({
|
createPage({
|
||||||
path: slug,
|
path: slug,
|
||||||
component: apiSwaggerTemplate,
|
component: apiSwaggerTemplate,
|
||||||
context: {
|
context: {
|
||||||
slug,
|
slug,
|
||||||
name: component,
|
name: component.name,
|
||||||
api: await fetchSwaggerSpec(component)
|
api: await fetchSwaggerSpec(component.url)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user