|
| 1 | +--- |
| 2 | +name: yapi |
| 3 | +description: Query and sync YApi interface documentation. Use when user mentions "yapi 接口文档", YAPI docs, asks for request/response details, or needs docs sync. |
| 4 | +--- |
| 5 | + |
| 6 | +# YApi interface docs |
| 7 | + |
| 8 | +## Workflow |
| 9 | +1. Load config from `~/.yapi/config.toml` (base_url, auth_mode, email/password or token, optional project_id). |
| 10 | +2. Identify the target interface by id or keyword; ask for project/category ids if needed. |
| 11 | +3. Call YApi endpoints with the CLI (see examples below) to fetch raw JSON. |
| 12 | +4. Summarize method, path, headers, query/body schema, response schema, and examples. |
| 13 | + |
| 14 | +## CLI |
| 15 | +- Install & run: `npx -y @leeguoo/yapi-mcp yapi -h` (or install globally and use `yapi`). |
| 16 | +- Use the same config as the skill: `~/.yapi/config.toml`. |
| 17 | +- Examples: |
| 18 | + - `yapi --path /api/interface/get --query id=123` |
| 19 | + - `yapi search --q keyword` |
| 20 | + - `yapi whoami` |
| 21 | + |
| 22 | +## Docs sync |
| 23 | +- Bind local docs to YApi category with `yapi docs-sync bind add --name <binding> --dir <path> --project-id <id> --catid <id>` (stored in `.yapi/docs-sync.json`). |
| 24 | +- Sync with `yapi docs-sync --binding <binding>` or run all bindings with `yapi docs-sync`. |
| 25 | +- Default syncs only changed files; use `--force` to sync everything. |
| 26 | +- Mermaid rendering depends on `mmdc` (auto-installed if possible; failures do not block sync). |
| 27 | +- For full Markdown render, install `pandoc` (manual install required). |
| 28 | +- Extra mappings (generated after docs-sync run in binding mode): |
| 29 | + - `.yapi/docs-sync.links.json`: local docs to YApi doc URLs. |
| 30 | + - `.yapi/docs-sync.projects.json`: cached project metadata/envs. |
| 31 | + - `.yapi/docs-sync.deployments.json`: local docs to deployed URLs. |
| 32 | + |
| 33 | +## Interface creation tips |
| 34 | +- When adding interfaces, always set `req_body_type` (use `json` if unsure) and provide `res_body` (prefer JSON Schema). Empty values can make `/api/interface/add` fail. |
| 35 | +- Keep request/response structures in `req_*` / `res_body` instead of stuffing them into `desc` or `markdown`. |
0 commit comments