swagger.json•7.22 kB
{
"swagger": "2.0",
"info": {
"title": "示例API",
"description": "这是一个用于演示Swagger MCP服务器的示例API",
"version": "1.0.0",
"contact": {
"name": "API支持",
"email": "support@example.com"
}
},
"host": "jsonplaceholder.typicode.com",
"basePath": "",
"schemes": ["https"],
"consumes": ["application/json"],
"produces": ["application/json"],
"paths": {
"/posts": {
"get": {
"summary": "获取所有文章",
"description": "返回所有文章的列表",
"operationId": "getAllPosts",
"parameters": [
{
"name": "userId",
"in": "query",
"description": "按用户ID筛选文章",
"required": false,
"type": "integer"
},
{
"name": "_limit",
"in": "query",
"description": "限制返回的文章数量",
"required": false,
"type": "integer",
"minimum": 1,
"maximum": 100
}
],
"responses": {
"200": {
"description": "成功返回文章列表",
"schema": {
"type": "array",
"items": {
"$ref": "#/definitions/Post"
}
}
}
}
},
"post": {
"summary": "创建新文章",
"description": "创建一篇新的文章",
"operationId": "createPost",
"parameters": [
{
"name": "body",
"in": "body",
"description": "文章内容",
"required": true,
"schema": {
"$ref": "#/definitions/NewPost"
}
}
],
"responses": {
"201": {
"description": "文章创建成功",
"schema": {
"$ref": "#/definitions/Post"
}
}
}
}
},
"/posts/{id}": {
"get": {
"summary": "根据ID获取文章",
"description": "返回指定ID的文章详情",
"operationId": "getPostById",
"parameters": [
{
"name": "id",
"in": "path",
"description": "文章ID",
"required": true,
"type": "integer"
}
],
"responses": {
"200": {
"description": "成功返回文章详情",
"schema": {
"$ref": "#/definitions/Post"
}
},
"404": {
"description": "文章未找到"
}
}
},
"put": {
"summary": "更新文章",
"description": "更新指定ID的文章",
"operationId": "updatePost",
"parameters": [
{
"name": "id",
"in": "path",
"description": "文章ID",
"required": true,
"type": "integer"
},
{
"name": "body",
"in": "body",
"description": "更新的文章内容",
"required": true,
"schema": {
"$ref": "#/definitions/UpdatePost"
}
}
],
"responses": {
"200": {
"description": "文章更新成功",
"schema": {
"$ref": "#/definitions/Post"
}
}
}
},
"delete": {
"summary": "删除文章",
"description": "删除指定ID的文章",
"operationId": "deletePost",
"parameters": [
{
"name": "id",
"in": "path",
"description": "文章ID",
"required": true,
"type": "integer"
}
],
"responses": {
"200": {
"description": "文章删除成功"
}
}
}
},
"/users": {
"get": {
"summary": "获取所有用户",
"description": "返回所有用户的列表",
"operationId": "getAllUsers",
"parameters": [
{
"name": "email",
"in": "query",
"description": "按邮箱筛选用户",
"required": false,
"type": "string"
}
],
"responses": {
"200": {
"description": "成功返回用户列表",
"schema": {
"type": "array",
"items": {
"$ref": "#/definitions/User"
}
}
}
}
}
},
"/users/{id}": {
"get": {
"summary": "根据ID获取用户",
"description": "返回指定ID的用户详情",
"operationId": "getUserById",
"parameters": [
{
"name": "id",
"in": "path",
"description": "用户ID",
"required": true,
"type": "integer"
}
],
"responses": {
"200": {
"description": "成功返回用户详情",
"schema": {
"$ref": "#/definitions/User"
}
},
"404": {
"description": "用户未找到"
}
}
}
}
},
"definitions": {
"Post": {
"type": "object",
"properties": {
"id": {
"type": "integer",
"description": "文章ID"
},
"userId": {
"type": "integer",
"description": "作者用户ID"
},
"title": {
"type": "string",
"description": "文章标题"
},
"body": {
"type": "string",
"description": "文章内容"
}
}
},
"NewPost": {
"type": "object",
"required": ["title", "body", "userId"],
"properties": {
"title": {
"type": "string",
"description": "文章标题"
},
"body": {
"type": "string",
"description": "文章内容"
},
"userId": {
"type": "integer",
"description": "作者用户ID"
}
}
},
"UpdatePost": {
"type": "object",
"properties": {
"title": {
"type": "string",
"description": "文章标题"
},
"body": {
"type": "string",
"description": "文章内容"
},
"userId": {
"type": "integer",
"description": "作者用户ID"
}
}
},
"User": {
"type": "object",
"properties": {
"id": {
"type": "integer",
"description": "用户ID"
},
"name": {
"type": "string",
"description": "用户姓名"
},
"username": {
"type": "string",
"description": "用户名"
},
"email": {
"type": "string",
"description": "邮箱地址"
},
"phone": {
"type": "string",
"description": "电话号码"
},
"website": {
"type": "string",
"description": "个人网站"
}
}
}
}
}