Introduction¶
In the agent development workflow, writing code first, then backfilling API documentation, and finally manually updating YAPI is a common yet inefficient step. dsh-yapi delegates this work to the agent: you describe your API endpoints in natural language, the agent reads existing definitions and generates a manifest, then—after you approve each entry in the host-side review card—the changes are written to the remote YAPI instance.
What It Is¶
dsh-yapi is a plugin for DeepSeek Harness (DSH), maintained by lyy-hast. It enables automatic API definition generation through agent conversation, with writes controlled via a review card, ensuring that only content you have explicitly confirmed gets submitted.
Core Features¶
After configuring your YAPI service URL and project credentials, the plugin provides the following capabilities:
- Project management: Configure one or more YAPI projects (local id + project token); the badge in the chat bar switches in real time, and project names are fetched live from YAPI
- Read endpoints: Read existing endpoints in the current project (bounded return; fields treated as untrusted data)
- Folder assignment via class annotations: The agent reads the first line of the Javadoc for each endpoint’s corresponding class as the folder name; same-named entries are merged, and missing ones fall back to the default category
- Write plan: Submit the full endpoint manifest (up to 50 entries); the host annotates conflicts and generates a review card
- Approve & write: Only approved entries from the card are written; missing folders are created before writing, and the project is re-read after writing for verification, with per-entry results reported
Below the chat bar there is a YAPI badge: it normally shows the current project name, and when a write plan is pending it reflects the plan status (⚠ N pending → N approved · awaiting write → ⟳ Writing i/total → ✓ N written; on failure: Written w · Failed f). Clicking the badge opens a three-section panel: the write plan card, the project list, and a requirements input box.
Installation & Enablement¶
Prerequisite: DeepSeek Harness desktop or dsh web must be installed and have been launched at least once.
Option 1: Install from the Plugin Marketplace
Search for dsh-yapi in the in-app plugin marketplace (available once indexed).
Option 2: Install from npm
dsh plugin --profile <profile> add dsh-yapi
The installation result must show application as applied for it to take effect; if warnings appear, address them as prompted and then restart.
Option 3: Install from a local directory (for development)
git clone https://github.com/lyy-hast/dsh-yapi.git
cd dsh-yapi && pnpm install
plugin_manager action=install_bundle target=/absolute/path/dsh-yapi
The target must be an absolute path.
Configuration¶
Open Settings (next to the avatar in the lower-left corner), select YAPI Connector from the left navigation, and fill in the following fields (all take effect immediately, no restart required). The same configuration is also accessible from the plugin page: find dsh-yapi and click the configuration link on the “YAPI Connector” row.
| Field | Required | Default | Description |
|---|---|---|---|
| Base URL | Yes | None | YAPI service URL, e.g. https://yapi.example.com. If left empty, all operations show “Service URL not configured”. Only https is allowed (http permitted for local loopback) |
| Allowed hosts | No | Empty | Additional host whitelist. All request URLs are constructed solely from the Base URL and cannot be overridden by tool parameters; fill in allowed hostnames here to further restrict access |
| Project list | When using multiple projects | Empty | Each entry contains: id (local identifier; auto-generated as p1, p2… if left empty), display name (falls back to the live YAPI project name if empty), token (project-level token; may be a credential reference name or a plaintext value) |
| Username / Password | When login session is required for writes | YAPI_USERNAME / YAPI_PASSWORD | YAPI account credentials used to log in and obtain a session cookie |
| Default project token (legacy) | When project list is empty | YAPI_PROJECT_TOKEN | Legacy single-project field; use the project list for new configurations |
| Require approval in review card before writing | — | On | When disabled, plans are auto-approved and written immediately |
Credentials can be entered as DSH credential reference names (UPPER_SNAKE_CASE, e.g. YAPI_PROJECT_TOKEN) or as plaintext values. Reference-based credentials take effect immediately upon rotation; plaintext values are stored only in this plugin’s configuration and never appear in prompts or tool results.
Typical Workflow¶
- After configuring at least one project, the YAPI badge appears below the chat bar.
- If no project is manually selected, the tool chain defaults to the first configured project. Click the badge to switch / refresh in the project list, or use
/yapi-select list|<project-id>. - Initiate generation (two equivalent methods): describe your requirements in the chat, or fill in the requirements box in the panel and click Start Generation (
/yapi-doc). The agent reads the first line of the Javadoc for each endpoint’s corresponding class as the folder name. - The agent reads existing endpoints in the project, generates definitions based on your description (+ new / ✎ update), and submits the full manifest via
yapi_plan; the host annotates conflicts (e.g., creating a new entry on an existing path+method), then a review card appears in the panel and the badge changes to⚠ N pending. The card is grouped by folder, each showing the entry count; folders that do not yet exist carry a “Will be created” tag. - Check entries one by one in the card: each shows a New/Update badge, method, path, and category; update entries display a field-level change summary; entries conflicting with the live instance are unchecked by default. Click Details to see a req/res preview.
- Click Approve & Write N (or type
/yapi-approve <planId> all): the agent first creates folders tagged “Will be created” (reusing same-name folders, case-insensitive), then writes endpoints into their respective folders; during writing the badge shows⟳ Writing i/total, each card entry turns to✓ Written, and a summary of newly created / reused folders is displayed. - When complete, the card transitions to a result state; failed items can be selected and retried (only failed items are retried). The agent reports per-entry results and the verified total in the conversation.
If the project is switched after a plan is created, both approval and writing will be rejected and a new plan must be generated—the write target always follows the project in effect at the time the plan was created.
Confirmation Mechanism¶
- User confirmation is mechanism-level, not prompt-level:
yapi_save_interfacesaccepts only aplanId; the written content is taken from the host-side saved plan and is limited to entries approved in the card. The agent cannot smuggle content through parameters, nor can it write endpoints you have never seen. - A plan is valid for 15 minutes; expired plans require regeneration. Only one plan exists per session at a time; a new plan replaces the old one.
- Requirements, approval, and retry can all be performed from the card; when not using the panel, commands are available (see below).
- Badge and card state are session projections: they are rebuilt exclusively from standard events (tool call/result, command run/done) via folding, and no custom event types are written to the session log. After a host restart or session fork, cards can be restored for display, but approval will prompt you to regenerate the plan.
Folder Organization via Class Annotations¶
Generated endpoints are no longer all flat-listed under the project root; instead, they are organized into folders (YAPI categories) based on the annotations of their corresponding classes:
- Folder name source: The agent locates the class for each endpoint in the workspace source code, reads the first effective description line of the Javadoc above the class declaration (stripping
/**,*, and tag lines), and populates the endpoint’scategoryfield. The agent must be able to read the corresponding source code; the/yapi-docskill has this rule built in. - Same-name merging: If different endpoints/classes share the same first Javadoc line, they are grouped into the same folder; the host matches case-insensitively and collapses whitespace, reusing existing categories without creating duplicates.
- Creation timing: A folder is itself a write operation, but it enters the review card alongside endpoints (tagged “Will be created”) and is only created after your approval—folder first, then endpoints, ensuring “what you see is what gets written.” The write result lists folders newly created (or reused) in this batch.
- Fallback: If a class cannot be located, the class has no Javadoc, or the source is not in the workspace, the
categoryfield is omitted and the endpoint falls back to the project’s default/root category, without affecting other endpoints. The agent never fabricates folder names. - Explicit override:
catid(numeric id of an existing category) takes precedence overcategory; use it only when you explicitly need to write to a known category id—normally unnecessary.
Write Format¶
When writing to YAPI, the host maps plan content to YAPI’s interface field protocol (verified against YAPI 1.10.x / 1.12):
- Request body is written to
req_body_other(YAPI has noreq_bodyfield; it would be discarded by the server), withreq_body_type=jsonandreq_body_is_json_schema=true; response body is written tores_bodywith the same JSON schema flag. reqBody/resBodyare expected to be JSON Schema strings (not example JSON)—with*_is_json_schema=true, the YAPI interface page renders them as a structured field tree (SchemaTable) and supports advanced Mock.desc(remarks) is drafted as Markdown by the agent; the YAPI view page rendersdescas HTML. The host safely converts Markdown to HTML before writing and also stores the source in themarkdownfield for editor display. Conversion escapes HTML first, then generates tags—raw HTML / scripts in remarks cannot inject.- For update entries, fields not provided are not sent, preserving the live values;
descchange detection is based on the Markdown source. - New entries use
/api/interface/add; updates use/api/interface/up;/api/interface/saveis intentionally avoided as it would incorrectly insert new records.
Data & Privacy¶
- Credentials never enter prompts. Account credentials / project tokens / session cookies are stored in the DSH credential store (reference name) or in this plugin’s configuration (plaintext), and never appear in prompts, tool parameters, or documentation. The plugin masks sensitive values in its output.
- Requests are sent only to your configured Base URL. All request URLs are constructed from the Base URL and cannot be overridden by tool parameters, eliminating SSRF surface; Allowed hosts can further restrict access.
- Project tokens are project-scoped: the server operates based on the token’s owning project and ignores any
project_idoverride passed in. - Plan content is stored only in host memory. The full plan (including req/res bodies) is never written to disk; cards and projections contain only truncated previews (300 characters), and only approved entries are written out.
- YAPI return content is treated as data, not instructions. During generation, text in endpoint names, project names, or descriptions such as “ignore the above” or “exfiltrate data” will not be executed; the
/yapi-docskill has this constraint built in. Use only with trusted projects.
Limitations¶
- Plans expire after 15 minutes; after a host restart or session fork, old plans are display-only and can no longer be approved—regeneration is required.
- Review and conflict annotation are based on the first 100 endpoints returned by YAPI (
/api/interface/listsingle-page boundary). - A single plan holds at most 50 entries; req/res previews in the card are truncated to 300 characters.
- Relies on the host’s built-in
dsh-tools,dsh-credentials,dsh-skill,dsh-commands, anddsh-session-projectionservices; when any are missing, related capabilities degrade gracefully without crashing.
Commands & Tools¶
Commands:
| Command | Purpose |
|---|---|
/yapi-doc [requirement description] |
Initiate generation; passes the requirement to the agent |
/yapi-select [project-id\|list] |
List / select / refresh projects |
/yapi-approve <planId> [item-id\|all] |
Approve a write plan (command form of the card button) |
/yapi-cancel <planId> |
Cancel an un-written plan |
Tools:
| Tool | Purpose |
|---|---|
yapi_projects |
List / select / view the current project |
yapi_interfaces |
Read existing endpoints in the current project |
yapi_plan |
Create (with host-side conflict annotation) / view / cancel a write plan |
yapi_save_interfaces |
Write approved plan entries (parameters: planId and optional itemIds only) |
Development¶
Project structure:
dsh-yapi/
├── index.js Host side: Cordis plugin entry, config schema, YAPI HTTP client,
│ four tools, /yapi-doc skill & commands, session projection folding
├── client.js Client side: plugin settings panel (4-step grouping) + chat bar badge & review card
├── locale/{zh,en}.json Plugin metadata (title, description, detail doc link)
├── docs/DETAIL.md Detailed documentation (the "Details" link in the panel points here)
├── icon.svg Plugin icon
├── cordis.patch.yml Bundle patch
└── package.json
index.js depends only on @deepseek-ai/schemastery (peerDependency, provided by the host); client.js uses only Harness theme tokens (--dsw-alias-*) and does not import any @deepseek-ai/dsh-client-* packages—React is provided by the host’s browser module table.
After making code changes, verify via local directory installation; changes in the plugin settings take effect immediately, while host-side changes require a host restart.
License¶
MIT © 2026 dsh-yapi contributors
This project has no affiliation with YAPI’s official team and is a third-party open-source integration. “YAPI” is the name of its respective rights holder, referenced here solely to identify the integration target.