名称: api-mock-server 描述: 根据OpenAPI规范生成和运行模拟API服务器 允许使用的工具:
- Bash
- Read
- Write
- Glob
API模拟服务器技能
概述
根据OpenAPI规范生成和运行模拟API服务器,具备动态响应生成、请求验证以及Prism/Mockoon集成功能。
能力
- 根据OpenAPI规范生成模拟服务器
- 基于模式动态生成响应
- 根据规范验证请求
- Prism和Mockoon集成
- 自定义响应场景
- 回调和Webhook模拟
- 有状态的模拟行为
目标流程
- api-design-specification
- microservices-decomposition
输入模式
{
"type": "object",
"required": ["specPath"],
"properties": {
"specPath": {
"type": "string",
"description": "OpenAPI规范文件路径"
},
"port": {
"type": "number",
"default": 4010
},
"engine": {
"type": "string",
"enum": ["prism", "mockoon", "custom"],
"default": "prism"
},
"options": {
"type": "object",
"properties": {
"dynamic": {
"type": "boolean",
"default": true,
"description": "生成动态响应"
},
"validateRequest": {
"type": "boolean",
"default": true
},
"cors": {
"type": "boolean",
"default": true
},
"scenarios": {
"type": "array",
"description": "自定义响应场景"
}
}
}
}
}
输出模式
{
"type": "object",
"properties": {
"serverUrl": {
"type": "string"
},
"port": {
"type": "number"
},
"endpoints": {
"type": "array",
"items": {
"type": "object",
"properties": {
"method": { "type": "string" },
"path": { "type": "string" }
}
}
},
"pid": {
"type": "number",
"description": "运行服务器的进程ID"
}
}
}
使用示例
{
kind: 'skill',
skill: {
name: 'api-mock-server',
context: {
specPath: 'api/openapi.yaml',
port: 4010,
engine: 'prism',
options: {
dynamic: true,
validateRequest: true
}
}
}
}