feat: adds openapi documentation

This commit is contained in:
Iain Learmonth 2025-05-21 13:59:53 +01:00
parent 5ee45209d8
commit b066849d90
6 changed files with 4041 additions and 2 deletions

View file

@ -4,6 +4,7 @@ pages:
stage: deploy
script:
- npm install
- npm run docusaurus gen-api-docs api
- npm run build
- cp -r static/* build/
- mv build public

View file

@ -1,6 +1,7 @@
import {themes as prismThemes} from 'prism-react-renderer';
import type {Config} from '@docusaurus/types';
import type * as Preset from '@docusaurus/preset-classic';
import type * as OpenApiPlugin from "docusaurus-plugin-openapi-docs";
// This runs in Node.js - Don't use client-side code here (browser APIs, JSX...)
@ -29,6 +30,7 @@ const config: Config = {
{
docs: {
sidebarPath: './sidebars.ts',
docItemComponent: "@theme/ApiItem",
},
theme: {
customCss: './src/css/custom.css',
@ -37,6 +39,28 @@ const config: Config = {
],
],
plugins: [
[
'docusaurus-plugin-openapi-docs',
{
id: "api", // plugin id
docsPluginId: "classic", // configured for preset-classic
config: {
api: {
specPath: "static/openapi.json",
outputDir: "docs/api/",
downloadUrl: "/openapi.json",
sidebarOptions: {
groupPathsBy: "tag",
categoryLinkSource: "tag",
},
} satisfies OpenApiPlugin.Options,
}
},
]
],
themes: ["docusaurus-theme-openapi-docs"], // export theme components
themeConfig: {
// Replace with your project's social card
image: 'img/docusaurus-social-card.jpg',
@ -53,6 +77,12 @@ const config: Config = {
position: 'left',
label: 'Docs',
},
{
type: 'docSidebar',
sidebarId: 'apisidebar',
position: 'left',
label: 'API',
},
{
to: '/contact',
position: 'left',

4004
package-lock.json generated

File diff suppressed because it is too large Load diff

View file

@ -20,6 +20,8 @@
"@docusaurus/preset-classic": "3.7.0",
"@mdx-js/react": "^3.0.0",
"clsx": "^2.0.0",
"docusaurus-plugin-openapi-docs": "^4.4.0",
"docusaurus-theme-openapi-docs": "^4.4.0",
"prism-react-renderer": "^2.3.0",
"react": "^18.0.0",
"react-dom": "^18.0.0"

View file

@ -1,4 +1,5 @@
import type {SidebarsConfig} from '@docusaurus/plugin-content-docs';
import * as apiSidebar from './docs/api/sidebar';
// This runs in Node.js - Don't use client-side code here (browser APIs, JSX...)
@ -14,8 +15,8 @@ import type {SidebarsConfig} from '@docusaurus/plugin-content-docs';
*/
const sidebars: SidebarsConfig = {
// By default, Docusaurus generates a sidebar from the docs folder structure
tutorialSidebar: [{type: 'autogenerated', dirName: '.'}],
tutorialSidebar: ['intro', {'label': "Censorship 101", 'type': "category", items: [{'type': 'autogenerated', dirName: 'censorship'}]}],
apisidebar: apiSidebar.default,
// But you can create a sidebar manually
/*
tutorialSidebar: [

1
static/openapi.json Normal file

File diff suppressed because one or more lines are too long