update-api-docs
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseUpdate API Documentation
更新API文档
This skill guides you through updating the API reference documentation from the production OpenAPI specification.
本技能将引导你从生产环境的OpenAPI规范更新API参考文档。
Overview
概述
The API documentation is generated from an OpenAPI spec using . The workflow involves:
docusaurus-plugin-openapi-docs- Downloading the latest from production
openapi.json - Replacing the local spec file
- Regenerating the API documentation pages
API文档是通过从OpenAPI规范生成的。工作流程包括:
docusaurus-plugin-openapi-docs- 从生产环境下载最新的
openapi.json - 替换本地规范文件
- 重新生成API文档页面
File Locations
文件位置
| Purpose | Path |
|---|---|
| OpenAPI spec (source) | |
| Generated API docs | |
| Generated sidebar | |
| Docusaurus config | |
| 用途 | 路径 |
|---|---|
| OpenAPI规范(源文件) | |
| 生成的API文档 | |
| 生成的侧边栏 | |
| Docusaurus配置文件 | |
Steps
步骤
1. Download the OpenAPI spec from production
1. 从生产环境下载OpenAPI规范
bash
curl -s "https://cloud.agenta.ai/api/openapi.json" -o docs/docs/reference/openapi.jsonImportant: The file should be saved in minified format (single line, no pretty-printing) to match the existing format in the repository. The curl command above preserves the original format from the server.
bash
curl -s "https://cloud.agenta.ai/api/openapi.json" -o docs/docs/reference/openapi.json重要提示: 文件应以压缩格式(单行,无美化排版)保存,以匹配仓库中的现有格式。上述curl命令会保留服务器返回的原始格式。
2. Install dependencies (if needed)
2. 安装依赖(如有需要)
If this is a fresh clone or dependencies haven't been installed:
bash
cd docs
npm install如果是全新克隆仓库或尚未安装依赖:
bash
cd docs
npm install3. Clean existing generated API docs
3. 清理已生成的现有API文档
bash
cd docs
npm run clean-api-docs -- agentaThe argument refers to the OpenAPI config ID defined in .
agentadocusaurus.config.tsbash
cd docs
npm run clean-api-docs -- agentaagentadocusaurus.config.ts4. Regenerate API docs
4. 重新生成API文档
bash
cd docs
npm run gen-api-docs -- agentaThis will generate:
- Individual files for each endpoint
.api.mdx - files for API categories
.tag.mdx - for navigation
sidebar.ts
bash
cd docs
npm run gen-api-docs -- agenta此命令将生成:
- 每个接口对应的独立文件
.api.mdx - API分类对应的文件
.tag.mdx - 用于导航的文件
sidebar.ts
5. Verify the changes
5. 验证更改
Optionally, start the dev server to preview:
bash
cd docs
npm run startThen visit to verify the API docs render correctly.
http://localhost:5000/docs/reference/api(可选)启动开发服务器进行预览:
bash
cd docs
npm run start然后访问验证API文档是否正确渲染。
http://localhost:5000/docs/reference/apiCommit Guidelines
提交指南
When committing these changes:
-
First commit - API docs update:
docs(api): update OpenAPI spec from production -
Include all changed files:
docs/docs/reference/openapi.jsondocs/docs/reference/api/*.api.mdxdocs/docs/reference/api/*.tag.mdxdocs/docs/reference/api/sidebar.ts
提交更改时:
-
首次提交 - API文档更新:
docs(api): update OpenAPI spec from production -
包含所有更改的文件:
docs/docs/reference/openapi.jsondocs/docs/reference/api/*.api.mdxdocs/docs/reference/api/*.tag.mdxdocs/docs/reference/api/sidebar.ts
Troubleshooting
故障排除
"missing required argument 'id'" error
出现“missing required argument 'id'”错误
The clean and generate commands require the config ID. Use:
bash
npm run clean-api-docs -- agenta
npm run gen-api-docs -- agenta清理和生成命令需要配置ID,请使用:
bash
npm run clean-api-docs -- agenta
npm run gen-api-docs -- agenta"docusaurus: not found" error
出现“docusaurus: not found”错误
Run in the directory first.
npm installdocs/先在目录下运行。
docs/npm installDeprecation warning about onBrokenMarkdownLinks
关于onBrokenMarkdownLinks的弃用警告
This is a known warning and can be safely ignored. It will be addressed in a future Docusaurus v4 migration.
这是已知警告,可以安全忽略。该问题将在未来的Docusaurus v4迁移中解决。
Related Configuration
相关配置
The OpenAPI plugin is configured in :
docs/docusaurus.config.tstypescript
[
"docusaurus-plugin-openapi-docs",
{
id: "openapi",
docsPluginId: "classic",
config: {
agenta: {
specPath: "docs/reference/openapi.json",
outputDir: "docs/reference/api",
downloadUrl: "https://raw.githubusercontent.com/Agenta-AI/agenta/refs/heads/main/docs/docs/reference/openapi.json",
sidebarOptions: {
groupPathsBy: "tag",
categoryLinkSource: "tag",
},
},
},
},
],OpenAPI插件在中配置:
docs/docusaurus.config.tstypescript
[
"docusaurus-plugin-openapi-docs",
{
id: "openapi",
docsPluginId: "classic",
config: {
agenta: {
specPath: "docs/reference/openapi.json",
outputDir: "docs/reference/api",
downloadUrl: "https://raw.githubusercontent.com/Agenta-AI/agenta/refs/heads/main/docs/docs/reference/openapi.json",
sidebarOptions: {
groupPathsBy: "tag",
categoryLinkSource: "tag",
},
},
},
},
],