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/',
|
||||
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 { 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)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user