1
0
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:
Akshay 2021-08-19 15:44:56 +02:00 committed by GitHub
parent 81d00c61ac
commit a9bd6607f3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 16 additions and 9 deletions

View File

@ -68,5 +68,15 @@ module.exports = {
from: '/concepts/connect-to-networks/',
to: '/concepts/networks/'
}
],
swaggerComponents: [
{
name: 'aquarius',
url: 'https://aquarius.oceanprotocol.com/spec'
},
{
name: 'provider',
url: 'https://provider.mainnet.oceanprotocol.com/spec'
}
]
}

View File

@ -3,7 +3,7 @@
const path = require('path')
const { createFilePath } = require('gatsby-source-filesystem')
const Swagger = require('swagger-client')
const { redirects } = require('./config')
const { redirects, swaggerComponents } = require('./config')
exports.onCreateNode = ({ node, getNode, actions }) => {
const { createNodeField } = actions
@ -213,11 +213,9 @@ const createTypeDocPage = async (createPage, name, downloadUrl) => {
// Create pages from swagger json files
//
// https://github.com/swagger-api/swagger-js
const fetchSwaggerSpec = async (component) => {
const fetchSwaggerSpec = async (url) => {
try {
const client = await Swagger(
`https://${component}.mainnet.oceanprotocol.com/spec`
)
const client = await Swagger(url)
return client.spec // The resolved spec
// client.originalSpec // In case you need it
@ -234,21 +232,20 @@ const fetchSwaggerSpec = async (component) => {
}
const createSwaggerPages = async (createPage) => {
const swaggerComponents = ['aquarius', 'provider']
const apiSwaggerTemplate = path.resolve('./src/templates/Swagger/index.jsx')
const getSlug = (name) => `/references/${name}/`
for (const component of swaggerComponents) {
const slug = getSlug(component)
const slug = getSlug(component.name)
createPage({
path: slug,
component: apiSwaggerTemplate,
context: {
slug,
name: component,
api: await fetchSwaggerSpec(component)
name: component.name,
api: await fetchSwaggerSpec(component.url)
}
})
}