Loading...
Loading...
Compare original and translation side by side
| Pattern | Framework | Trigger Reason |
|---|---|---|
| Express/Fastify | Route definitions |
| NestJS/Express | Controller endpoints |
| NestJS | Controller class |
| FastAPI/Flask | API endpoints |
| FastAPI | Router definitions |
| Go | HTTP handlers |
| TypeScript | Schema definitions |
| NestJS | Data transfer objects |
| Various | API models |
| 模式 | 框架 | 触发原因 |
|---|---|---|
| Express/Fastify | 路由定义 |
| NestJS/Express | 控制器端点 |
| NestJS | 控制器类 |
| FastAPI/Flask | API端点 |
| FastAPI | 路由定义 |
| Go | HTTP处理器 |
| TypeScript | 模式定义 |
| NestJS | 数据传输对象 |
| 各类框架 | API模型 |
| File | Format | Standard |
|---|---|---|
| YAML | OpenAPI 3.x |
| JSON | OpenAPI 3.x |
| YAML | Swagger 2.0 |
| JSON | Swagger 2.0 |
| YAML | OpenAPI 3.x |
| YAML | OpenAPI 3.x |
| 文件 | 格式 | 标准 |
|---|---|---|
| YAML | OpenAPI 3.x |
| JSON | OpenAPI 3.x |
| YAML | Swagger 2.0 |
| JSON | Swagger 2.0 |
| YAML | OpenAPI 3.x |
| YAML | OpenAPI 3.x |
undefinedundefinedundefinedundefinedfind_api_docs() {
for file in openapi.yaml openapi.json swagger.yaml swagger.json \
docs/api.yaml docs/openapi.yaml api/openapi.yaml; do
if [ -f "$file" ]; then
echo "$file"
return 0
fi
done
return 1
}
DOC_FILE=$(find_api_docs)
if [ -z "$DOC_FILE" ]; then
echo "ERROR: No API documentation file found"
echo "PAUSE: Trigger documentation-audit skill"
fifind_api_docs() {
for file in openapi.yaml openapi.json swagger.yaml swagger.json \
docs/api.yaml docs/openapi.yaml api/openapi.yaml; do
if [ -f "$file" ]; then
echo "$file"
return 0
fi
done
return 1
}
DOC_FILE=$(find_api_docs)
if [ -z "$DOC_FILE" ]; then
echo "ERROR: No API documentation file found"
echo "PAUSE: Trigger documentation-audit skill"
fiverify_api_sync() {
local doc_file=$1
# Extract endpoints from code
CODE_ENDPOINTS=$(find . -name "*.ts" -path "*/routes/*" -exec grep -h "@(Get|Post|Put|Delete|Patch)" {} \; | \
sed 's/.*@\(Get\|Post\|Put\|Delete\|Patch\)(\([^)]*\)).*/\1 \2/' | sort -u)
# Extract endpoints from OpenAPI
DOC_ENDPOINTS=$(yq '.paths | keys[]' "$doc_file" 2>/dev/null | sort -u)
# Compare
MISSING=$(comm -23 <(echo "$CODE_ENDPOINTS" | sort) <(echo "$DOC_ENDPOINTS" | sort))
if [ -n "$MISSING" ]; then
echo "DRIFT DETECTED: Endpoints in code but not in docs:"
echo "$MISSING"
return 1
fi
return 0
}verify_api_sync() {
local doc_file=$1
# Extract endpoints from code
CODE_ENDPOINTS=$(find . -name "*.ts" -path "*/routes/*" -exec grep -h "@(Get|Post|Put|Delete|Patch)" {} \; | \
sed 's/.*@\(Get\|Post\|Put\|Delete\|Patch\)(\([^)]*\)).*/\1 \2/' | sort -u)
# Extract endpoints from OpenAPI
DOC_ENDPOINTS=$(yq '.paths | keys[]' "$doc_file" 2>/dev/null | sort -u)
# Compare
MISSING=$(comm -23 <(echo "$CODE_ENDPOINTS" | sort) <(echo "$DOC_ENDPOINTS" | sort))
if [ -n "$MISSING" ]; then
echo "DRIFT DETECTED: Endpoints in code but not in docs:"
echo "$MISSING"
return 1
fi
return 0
}undefinedundefinedPOST /api/usersroutes/users.ts:45GET /api/users/:id/profileroutes/users.ts:67POST /api/usersroutes/users.ts:45GET /api/users/:id/profileroutes/users.ts:67documentation-audit
Then invoke documentation-audit:
undefineddocumentation-audit
随后调用documentation-audit技能:
undefined| Field | Description |
|---|---|
| Short description of endpoint |
| Detailed explanation |
| All path/query/header params |
| Request schema with examples |
| All response codes with schemas |
| Grouping for organization |
| Auth requirements |
| 字段 | 说明 |
|---|---|
| 端点的简短描述 |
| 详细说明 |
| 所有路径/查询/头部参数 |
| 带示例的请求模式 |
| 带模式的所有响应码 |
| 用于分类的标签 |
| 认证要求 |
/api/users:
post:
summary: Create a new user
description: |
Creates a new user account with the provided details.
Requires admin authentication.
tags:
- Users
security:
- bearerAuth: []
requestBody:
required: true
content:
application/json:
schema:
$ref: '#/components/schemas/CreateUserRequest'
example:
email: user@example.com
name: John Doe
role: member
responses:
'201':
description: User created successfully
content:
application/json:
schema:
$ref: '#/components/schemas/User'
example:
id: usr_123abc
email: user@example.com
name: John Doe
role: member
createdAt: '2025-01-02T10:30:00Z'
'400':
description: Invalid request body
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
example:
code: VALIDATION_ERROR
message: Email is required
'401':
description: Authentication required
'403':
description: Insufficient permissions/api/users:
post:
summary: Create a new user
description: |
Creates a new user account with the provided details.
Requires admin authentication.
tags:
- Users
security:
- bearerAuth: []
requestBody:
required: true
content:
application/json:
schema:
$ref: '#/components/schemas/CreateUserRequest'
example:
email: user@example.com
name: John Doe
role: member
responses:
'201':
description: User created successfully
content:
application/json:
schema:
$ref: '#/components/schemas/User'
example:
id: usr_123abc
email: user@example.com
name: John Doe
role: member
createdAt: '2025-01-02T10:30:00Z'
'400':
description: Invalid request body
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
example:
code: VALIDATION_ERROR
message: Email is required
'401':
description: Authentication required
'403':
description: Insufficient permissionsundefinedundefinedundefinedundefined| Skill | Purpose |
|---|---|
| Full documentation sync |
| Triggered during implementation |
| Validates documentation complete |
| 技能 | 用途 |
|---|---|
| 完成文档全量同步 |
| 在实现阶段触发 |
| 验证文档完整性 |