Skip to content
This repository was archived by the owner on Aug 7, 2025. It is now read-only.

Commit c5c4030

Browse files
auricomgemini-code-assist[bot]tac0turtle
authored
feat: api documentation (#603)
* feat: api documentation * fix * fix * Apply suggestions from code review Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com> --------- Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com> Co-authored-by: tac0turtle <[email protected]>
1 parent 6e5c1ba commit c5c4030

File tree

8 files changed

+1294
-2
lines changed

8 files changed

+1294
-2
lines changed

.vitepress/config.ts

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,19 @@
11
import { withMermaid } from "vitepress-plugin-mermaid";
2+
import { useSidebar } from 'vitepress-openapi'
3+
import spec from '../src/openapi-rpc.json' with { type: 'json' }
24

35
const telegramSVG = ` <svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
46
<path fill-rule="evenodd" clip-rule="evenodd" d="M24 12C24 18.6274 18.6274 24 12 24C5.37258 24 0 18.6274 0 12C0 5.37258 5.37258 0 12 0C18.6274 0 24 5.37258 24 12ZM12.43 8.85893C11.2628 9.3444 8.93014 10.3492 5.43189 11.8733C4.86383 12.0992 4.56626 12.3202 4.53917 12.5363C4.49339 12.9015 4.95071 13.0453 5.57347 13.2411C5.65818 13.2678 5.74595 13.2954 5.83594 13.3246C6.44864 13.5238 7.27283 13.7568 7.70129 13.766C8.08994 13.7744 8.52373 13.6142 9.00264 13.2853C12.2712 11.079 13.9584 9.96381 14.0643 9.93977C14.139 9.92281 14.2426 9.90148 14.3128 9.96385C14.3829 10.0262 14.376 10.1443 14.3686 10.176C14.3233 10.3691 12.5281 12.0381 11.5991 12.9018C11.3095 13.171 11.1041 13.362 11.0621 13.4056C10.968 13.5033 10.8721 13.5958 10.78 13.6846C10.2108 14.2333 9.78391 14.6448 10.8036 15.3168C11.2936 15.6397 11.6858 15.9067 12.077 16.1731C12.5042 16.4641 12.9303 16.7543 13.4816 17.1157C13.6221 17.2077 13.7562 17.3034 13.8869 17.3965C14.3841 17.751 14.8307 18.0694 15.3826 18.0186C15.7032 17.9891 16.0345 17.6876 16.2027 16.7884C16.6002 14.6631 17.3816 10.0585 17.5622 8.16097C17.578 7.99473 17.5581 7.78197 17.5422 7.68857C17.5262 7.59518 17.4928 7.46211 17.3714 7.3636C17.2276 7.24694 17.0056 7.22234 16.9064 7.22408C16.455 7.23203 15.7626 7.47282 12.43 8.85893Z" fill="currentColor"/>
57
</svg>`;
68

79
const { BASE: base = "/" } = process.env;
810

11+
const sidebar = useSidebar({
12+
spec,
13+
// Optionally, you can specify a link prefix for all generated sidebar items. Default is `/operations/`.
14+
linkPrefix: '/api/',
15+
})
16+
917
// https://vitepress.dev/reference/site-config
1018
export default withMermaid({
1119
lang: "en-US",
@@ -162,6 +170,7 @@ function nav() {
162170
{ text: "Learn", link: "/learn/about" },
163171
{ text: "How To Guides", link: "/guides/quick-start" },
164172
{ text: "Blog", link: "/blog/overview" },
173+
{ text: "API Documentation", link: "/api" },
165174
];
166175
}
167176

@@ -306,5 +315,18 @@ function sidebarHome() {
306315
collapsed: true,
307316
items: [{ text: "Overview", link: "/blog/overview" }],
308317
},
318+
{
319+
text: "API Documentation",
320+
collapsed: true,
321+
items: [
322+
{
323+
text: "Introduction",
324+
link: "/api",
325+
},
326+
...sidebar.generateSidebarGroups({
327+
linkPrefix: "/api/operationsByTags/"
328+
})
329+
]
330+
},
309331
];
310332
}

.vitepress/theme/index.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
import { h } from 'vue'
33
import Theme from 'vitepress/theme'
44
import './style.css'
5+
import { theme } from 'vitepress-openapi/client'
6+
import 'vitepress-openapi/dist/style.css'
57

68
export default {
79
extends: Theme,
@@ -11,6 +13,6 @@ export default {
1113
})
1214
},
1315
enhanceApp({ app, router, siteData }) {
14-
// ...
16+
theme.enhanceApp({ app, router, siteData })
1517
}
1618
}

api/index.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
---
2+
aside: false
3+
outline: false
4+
title: API Introduction
5+
---
6+
7+
<script setup>
8+
import spec from '../src/openapi-rpc.json'
9+
</script>
10+
11+
<OAIntroduction :spec="spec" />

api/operationsByTags/[operationId].md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
---
2+
aside: false
3+
outline: false
4+
title: API Operation Details
5+
---
6+
7+
<script setup lang="ts">
8+
import { useRoute } from 'vitepress'
9+
import spec from '../../src/openapi-rpc.json'
10+
11+
const route = useRoute()
12+
13+
const operationId = route.data.params.operationId
14+
</script>
15+
16+
<OAOperation :spec="spec" :operationId="operationId" />
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import { usePaths } from 'vitepress-openapi'
2+
import spec from '../../src/openapi-rpc.json' with {type: 'json'}
3+
4+
export default {
5+
paths() {
6+
return usePaths({ spec })
7+
.getPathsByVerbs()
8+
.map(({ operationId, summary }) => {
9+
return {
10+
params: {
11+
operationId,
12+
pageTitle: `${summary} - vitepress-openapi`,
13+
},
14+
}
15+
})
16+
},
17+
}

package.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,5 +13,8 @@
1313
"vitepress": "^1.5.0",
1414
"vitepress-plugin-mermaid": "^2.0.17"
1515
},
16+
"dependencies": {
17+
"vitepress-openapi": "^0.1.3"
18+
},
1619
"type": "module"
1720
}

0 commit comments

Comments
 (0)