From a9bd6607f344099c1bdd31bd15edddc995ecb91b Mon Sep 17 00:00:00 2001 From: Akshay Date: Thu, 19 Aug 2021 15:44:56 +0200 Subject: [PATCH] Feature: Update swagger spec urls (#719) --- config.js | 10 ++++++++++ gatsby-node.js | 15 ++++++--------- 2 files changed, 16 insertions(+), 9 deletions(-) diff --git a/config.js b/config.js index 4dc9cbb1..bdaac222 100644 --- a/config.js +++ b/config.js @@ -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' + } ] } diff --git a/gatsby-node.js b/gatsby-node.js index 330d4fa9..b88890bf 100755 --- a/gatsby-node.js +++ b/gatsby-node.js @@ -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) } }) }