Files
threshold/website/pages/api-docs/[[...page]].jsx
T
Zachary ShiltonandKyle MacDonald 1cc8737540 Add generated API docs to website (#537)
* Add dependencies for openapi-page component

* Add openapi-page component

* Use openapi-page component for /api-docs page

* add /api link to nav  (#570)

* website: remove superflous netlify config file

* website: misc clean up website/readme
- remove netlify badge
- run through prettier markdown fmt

* website: add /api docs to nav
- adds /api-docs => /api rewrite
- updates open-api component base api path to be /api
- adds .html rewrite for good measure

* Fix currentPath highlight issue in subnav

* Clean up inline styles in operation-object

* Remove React imports

* Remove api-docs rewrite

Co-authored-by: Kyle MacDonald <kylemac@users.noreply.github.com>
2020-10-09 13:26:32 -07:00

34 lines
923 B
React

import { productName, productSlug } from 'data/metadata'
import path from 'path'
import parseSwagger from '../../lib/swagger-parser'
import OpenApiPage, {
getPathsFromSchema,
getPropsForPage,
} from '../../components/openapi-page'
const targetFile = '../internal/gen/controller.swagger.json'
const pathFromRoot = 'api-docs'
export default function ExamplePage(props) {
return (
<OpenApiPage
{...props}
productName={productName}
productSlug={productSlug}
pathFromRoot={pathFromRoot}
/>
)
}
export async function getStaticPaths() {
const schema = await parseSwagger(path.join(process.cwd(), targetFile))
const paths = getPathsFromSchema(schema)
return { paths, fallback: false }
}
export async function getStaticProps({ params }) {
const schema = await parseSwagger(path.join(process.cwd(), targetFile))
const props = getPropsForPage(schema, params)
return { props }
}