Skip to content

Commit f45de9a

Browse files
authored
Nicer docusaurus openapi docs (LAION-AI#722)
- uses this plugin (https://github.com/cloud-annotations/docusaurus-openapi) to make a nice static site docusaurus based api section of docs site. - adds some nicer postman code snippets etc too as part of api docs. - makes api docs more "self hosted" as opposed to the dynamic swagger url approach.
1 parent 124994a commit f45de9a

File tree

3 files changed

+980
-44
lines changed

3 files changed

+980
-44
lines changed

docs/docusaurus.config.js

+5-6
Original file line numberDiff line numberDiff line change
@@ -32,12 +32,15 @@ const config = {
3232

3333
presets: [
3434
[
35-
"classic",
35+
"docusaurus-preset-openapi",
3636
/** @type {import('@docusaurus/preset-classic').Options} */
3737
({
3838
docs: {
3939
sidebarPath: require.resolve("./sidebars.js"),
4040
},
41+
api: {
42+
path: "docs/api/openapi.json",
43+
},
4144
blog: false,
4245
theme: {
4346
customCss: require.resolve("./src/css/custom.css"),
@@ -62,11 +65,7 @@ const config = {
6265
position: "left",
6366
label: "Docs",
6467
},
65-
{
66-
href: "https://editor.swagger.io/?url=https://raw.githubusercontent.com/LAION-AI/Open-Assistant/main/docs/docs/api/openapi.json",
67-
label: "API",
68-
position: "left",
69-
},
68+
{ to: "/api", label: "API", position: "left" },
7069
{
7170
href: "https://github.com/LAION-AI/Open-Assistant",
7271
label: "GitHub",

docs/package.json

+3-1
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,11 @@
1919
"@docusaurus/preset-classic": "2.2.0",
2020
"@mdx-js/react": "^1.6.22",
2121
"clsx": "^1.2.1",
22+
"docusaurus-preset-openapi": "^0.6.3",
2223
"prism-react-renderer": "^1.3.5",
2324
"react": "^17.0.2",
24-
"react-dom": "^17.0.2"
25+
"react-dom": "^17.0.2",
26+
"url": "^0.11.0"
2527
},
2628
"devDependencies": {
2729
"@docusaurus/module-type-aliases": "2.2.0",

0 commit comments

Comments
 (0)