feat: 从 FastAPI 导出 openapi.json 并渲染为 API 文档

通过 vitepress-openapi 插件,在 VitePress 文档中实现基于 openapi.json 的 API 文档。
这样实现的 API 文档可以从最新版本的代码库中提取路由信息,继而实现自动集成。
---
同时,通过 Kimi 和 Deepseek 实现并审查了一个对 Google 风格 docstring 的解析函数。
该函数可以从 Google 风格的 docstring 中提取参数文档并按 openapi 规范重新整理它们。
---
增加了 nyahome openapi 命令用来导出 openapi.json。
增加了 task openapi-docs 命令用来准备未来的持续集成。
This commit is contained in:
2026-05-25 14:56:36 +08:00
parent 3117af670b
commit e29f27e2eb
12 changed files with 755 additions and 19 deletions
+47
View File
@@ -1,4 +1,51 @@
:root {
--vp-c-brand-1: #64ffc4;
--vp-c-brand-2: #9354ff;
}
/* ===== 简约滚动条美化 ===== */
/* 适用于 Webkit 内核(Chrome/Edge/Safari */
::-webkit-scrollbar {
width: 6px;
/* 垂直滚动条宽度 */
height: 6px;
/* 水平滚动条高度 */
}
::-webkit-scrollbar-track {
background: transparent;
/* 轨道透明,极简 */
}
::-webkit-scrollbar-thumb {
background: rgba(255, 255, 255, 0.15);
/* 滑块半透明灰 */
border-radius: 3px;
/* 小圆角 */
}
::-webkit-scrollbar-thumb:hover {
background: rgba(255, 255, 255, 0.25);
/* 悬停稍微深一点 */
}
/* Firefox 兼容 */
* {
scrollbar-width: thin;
scrollbar-color: rgba(255, 255, 255, 0.15) transparent;
}
/* vitepress-openapi */
div.vitepress-openapi {
border: 1px solid #64ffc4;
border-radius: 6px;
margin: 48px auto 0;
padding: 6px 20px;
text-align: center;
}
div.vitepress-openapi p {
line-height: 8px;
}