This skill is dedicated to maintaining and updating the OpenAPI 3.0 interface documentation for Mingdao Cloud HAP (Host Application Platform), and supports synchronized management of Chinese and English bilingual documentation.
Use Cases
Use this skill in the following situations:
- The user needs to add an interface to the HAP documentation
- The user needs to modify the definition, parameters, or response structure of an existing interface
- The user needs to delete a deprecated interface
- The user needs to ensure that the Chinese and English documentation remain synchronized
- The user mentions keywords such as "HAP API documentation", "interface documentation", "OpenAPI", "add interface", "update interface", etc.
Documentation Structure
The HAP API documentation project contains two types of documentation:
1. Organization Authorization API Documentation
Located in the project root directory:
en/- English version organization authorization interface documentationzh-Hans/- Chinese version organization authorization interface documentation
2. Application API Documentation (v3-beta)
Located in the application directory:
application/en/- English version application interface documentationapplication/zh-Hans/- Chinese version application interface documentation
Each documentation directory contains:
openapi.yaml # 主文件,定义 tags、paths 路由
description.md # 文档描述
index.html # Redoc 预览页面
paths/ # 接口定义目录
├── user/ # 按功能模块分类
├── department/
└── ...
schemas/ # 数据模型目录
├── base/ # 基础模型
├── user/ # 用户相关模型
└── ...
Workflow
Add Interface
-
Determine the interface type and location
- Ask the user which module the interface belongs to (user/department/app, etc.)
- Determine whether it is an organization API or an application API
- Determine the HTTP method (GET/POST/PUT/DELETE, etc.)
-
Collect interface information
- Interface path (e.g.,
/v2/user/getExternalPortalUsers) - Interface summary and description
- Request parameters (query/body/path parameters)
- Response structure
- Whether authentication parameters are required (appKey, sign, timestamp, etc.)
- Interface path (e.g.,
-
Create file structure
For each language version (en and zh-Hans), perform the following operations:
a. Create the path definition file
- Location:
paths/{module}/{operationName}.yaml - Include: HTTP method, tags, summary, description, parameters/requestBody, responses
- Refer to
references/path_template.yamltemplates in
b. Create schema files (if needed)
- Request schema:
schemas/{module}/{operationName}Request.yaml - Response schema:
schemas/{module}/{operationName}Response.yaml - Data object:
schemas/{module}/{objectName}.yaml - Refer to
references/schema_template.yamltemplates in
c. Update openapi.yaml
- Add the new route in the paths section
- If there is a special server configuration, add the servers field
- Ensure grouping by module and keep the file tidy
- Location:
-
Verify consistency
- Ensure the Chinese and English versions have a consistent structure
- Check that all $ref reference paths are correct
- Verify that required fields are in the required array
Modify Interface
-
Locate files
- Use the Grep tool to search for the interface path or operationId
- Find the corresponding path file and related schema files
-
Synchronize modifications
- Also modify the corresponding files in the Chinese and English versions
- Keep the field structure consistent, only translate description and example
-
Update related files
- If a schema reference was modified, check other interfaces that use that schema
- If a path was modified, synchronously update openapi.yaml
Delete an interface
-
Remove the route from openapi.yaml
- Also delete the Chinese and English versions
-
Delete related files
- Delete the paths file
- Check whether the schemas are used by other interfaces; if not, delete them
-
Verify references
- Ensure that no other places reference the deleted files
Synchronize the Chinese and English documentation
-
Compare the structure
- Check whether the paths in openapi.yaml are consistent
- Compare the file directory structure
-
Synchronize differences
- Copy missing files
- Translate descriptive text
- Keep technical fields (type, format, required, etc.) completely consistent
Important specifications
Naming conventions
- File naming: Use camelCase naming, such as
getExternalPortalUsers.yaml - operationId: Keep consistent with the file name
- schema files: Use descriptive names, such as
externalPortalUser.yaml
Path reference conventions
- Reference paths from openapi.yaml:
'./paths/{module}/{file}.yaml' - Reference schemas from paths:
'../../schemas/{module}/{file}.yaml' - Reference other schemas from schemas:
'./{file}.yaml'
Request/response conventions
GET request: Use parameters to define query parameters
parameters:
- name: pageIndex
in: query
required: true
schema:
type: integer
POST request: Use requestBody to define the request body
requestBody:
required: true
content:
application/json:
schema:
$ref: '../../schemas/user/requestSchema.yaml'
Authentication parameters
Organization APIs usually require the following basic parameters:
appKey- App keysign- Signaturetimestamp- TimestampprojectId- Project ID
You can reference the base schema: $ref: ../../schemas/base/request/baseQueryAppkey.yaml
Response structure
Standard response format:
type: object
properties:
code:
type: integer
description: 状态码,1表示成功
message:
type: string
description: 状态描述
data:
type: object/array
description: 返回数据
Work checklist
After completing the documentation updates, perform the following checks:
- Both the Chinese and English versions have been updated
- Routes in openapi.yaml have been added/modified/deleted
- Path files have been created/modified/deleted
- Necessary schema files have been created
- All $ref reference paths are correct
- Required parameters are declared in the required array
- description provides clear explanations
- example provides valid example values
- The Chinese and English field structures are completely consistent (only descriptions differ)
Reference materials
For detailed templates and examples, see:
references/path_templates.md- API definition templatereferences/schema_templates.md- Data model templatereferences/common_patterns.md- Common patterns reference
Preview documentation
After modifications are complete, you can preview using Live Server:
- In VS Code, right-click
zh-Hans/index.htmloren/index.html - Select "Open With Live Server"
- The browser will open automatically and display the documentation rendered by Redoc