glam-web/openapi.json

316 lines
7.6 KiB
JSON

{
"openapi": "3.0.0",
"info": {
"title": "Outfit API",
"description": "服装搭配API",
"version": "1.0.0"
},
"servers": [
{
"url": "http://localhost:3000",
"description": "开发环境"
}
],
"paths": {
"/api/users": {
"get": {
"summary": "获取用户列表",
"tags": ["用户"],
"responses": {
"200": {
"description": "成功",
"content": {
"application/json": {
"schema": {
"type": "array",
"items": {
"$ref": "#/components/schemas/User"
}
}
}
}
}
}
},
"post": {
"summary": "创建用户",
"tags": ["用户"],
"requestBody": {
"required": true,
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/CreateUserRequest"
}
}
}
},
"responses": {
"201": {
"description": "创建成功",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/User"
}
}
}
}
}
}
},
"/api/users/{id}": {
"get": {
"summary": "获取用户详情",
"tags": ["用户"],
"parameters": [
{
"name": "id",
"in": "path",
"required": true,
"schema": {
"type": "string"
}
}
],
"responses": {
"200": {
"description": "成功",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/User"
}
}
}
}
}
},
"put": {
"summary": "更新用户",
"tags": ["用户"],
"parameters": [
{
"name": "id",
"in": "path",
"required": true,
"schema": {
"type": "string"
}
}
],
"requestBody": {
"required": true,
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/UpdateUserRequest"
}
}
}
},
"responses": {
"200": {
"description": "更新成功",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/User"
}
}
}
}
}
},
"delete": {
"summary": "删除用户",
"tags": ["用户"],
"parameters": [
{
"name": "id",
"in": "path",
"required": true,
"schema": {
"type": "string"
}
}
],
"responses": {
"204": {
"description": "删除成功"
}
}
}
},
"/api/outfits": {
"get": {
"summary": "获取搭配列表",
"tags": ["搭配"],
"responses": {
"200": {
"description": "成功",
"content": {
"application/json": {
"schema": {
"type": "array",
"items": {
"$ref": "#/components/schemas/Outfit"
}
}
}
}
}
}
},
"post": {
"summary": "创建搭配",
"tags": ["搭配"],
"requestBody": {
"required": true,
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/CreateOutfitRequest"
}
}
}
},
"responses": {
"201": {
"description": "创建成功",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/Outfit"
}
}
}
}
}
}
}
},
"components": {
"schemas": {
"User": {
"type": "object",
"properties": {
"id": {
"type": "string",
"description": "用户ID"
},
"username": {
"type": "string",
"description": "用户名"
},
"email": {
"type": "string",
"description": "邮箱"
},
"createdAt": {
"type": "string",
"format": "date-time",
"description": "创建时间"
},
"updatedAt": {
"type": "string",
"format": "date-time",
"description": "更新时间"
}
},
"required": ["id", "username", "email"]
},
"CreateUserRequest": {
"type": "object",
"properties": {
"username": {
"type": "string",
"description": "用户名"
},
"email": {
"type": "string",
"description": "邮箱"
},
"password": {
"type": "string",
"description": "密码"
}
},
"required": ["username", "email", "password"]
},
"UpdateUserRequest": {
"type": "object",
"properties": {
"username": {
"type": "string",
"description": "用户名"
},
"email": {
"type": "string",
"description": "邮箱"
}
}
},
"Outfit": {
"type": "object",
"properties": {
"id": {
"type": "string",
"description": "搭配ID"
},
"name": {
"type": "string",
"description": "搭配名称"
},
"description": {
"type": "string",
"description": "搭配描述"
},
"items": {
"type": "array",
"items": {
"type": "string"
},
"description": "服装项目列表"
},
"userId": {
"type": "string",
"description": "用户ID"
},
"createdAt": {
"type": "string",
"format": "date-time",
"description": "创建时间"
},
"updatedAt": {
"type": "string",
"format": "date-time",
"description": "更新时间"
}
},
"required": ["id", "name", "userId"]
},
"CreateOutfitRequest": {
"type": "object",
"properties": {
"name": {
"type": "string",
"description": "搭配名称"
},
"description": {
"type": "string",
"description": "搭配描述"
},
"items": {
"type": "array",
"items": {
"type": "string"
},
"description": "服装项目列表"
}
},
"required": ["name"]
}
}
}
}