Files
smart-crop-ui/crop-x/scripts/openapi.json

342 lines
8.2 KiB
JSON
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

{
"openapi": "3.1.0",
"info": {
"title": "Crop Admin API",
"description": "一个支持OpenAPI和前端代码自动生成的后台管理系统",
"version": "1.0.0"
},
"paths": {
"/api/v1/auth/login": {
"post": {
"tags": [
"认证"
],
"summary": "用户登录",
"description": "用户登录接口\n\n- **username**: 用户名\n- **password**: 密码\n\n返回JWT访问令牌",
"operationId": "login_api_v1_auth_login_post",
"requestBody": {
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/UserLogin"
}
}
},
"required": true
},
"responses": {
"200": {
"description": "Successful Response",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/APIResponse"
}
}
}
},
"422": {
"description": "Validation Error",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/HTTPValidationError"
}
}
}
}
}
}
},
"/api/v1/auth/register": {
"post": {
"tags": [
"认证"
],
"summary": "用户注册",
"description": "用户注册接口\n\n- **username**: 用户名 (必须唯一)\n- **password**: 密码\n\n注意这是一个演示版本实际生产环境需要更严格的验证",
"operationId": "register_api_v1_auth_register_post",
"requestBody": {
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/UserRegister"
}
}
},
"required": true
},
"responses": {
"200": {
"description": "Successful Response",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/APIResponse"
}
}
}
},
"422": {
"description": "Validation Error",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/HTTPValidationError"
}
}
}
}
}
}
},
"/api/v1/auth/me": {
"get": {
"tags": [
"认证"
],
"summary": "获取当前用户信息",
"description": "获取当前登录用户的信息",
"operationId": "get_current_user_api_v1_auth_me_get",
"responses": {
"200": {
"description": "Successful Response",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/APIResponse"
}
}
}
}
},
"security": [
{
"HTTPBearer": []
}
]
}
},
"/api/v1/auth/logout": {
"post": {
"tags": [
"认证"
],
"summary": "用户登出",
"description": "用户登出接口\n\n注意由于JWT是无状态的实际登出需要客户端删除token\n这里只是验证token并返回成功消息",
"operationId": "logout_api_v1_auth_logout_post",
"responses": {
"200": {
"description": "Successful Response",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/APIResponse"
}
}
}
}
},
"security": [
{
"HTTPBearer": []
}
]
}
},
"/api/v1/auth/users": {
"get": {
"tags": [
"认证"
],
"summary": "获取所有用户列表",
"description": "获取系统中所有用户的列表 (仅用于演示)",
"operationId": "get_all_users_api_v1_auth_users_get",
"responses": {
"200": {
"description": "Successful Response",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/APIResponse"
}
}
}
}
}
}
},
"/": {
"get": {
"summary": "Root",
"operationId": "root__get",
"responses": {
"200": {
"description": "Successful Response",
"content": {
"application/json": {
"schema": {}
}
}
}
}
}
},
"/health": {
"get": {
"summary": "Health Check",
"operationId": "health_check_health_get",
"responses": {
"200": {
"description": "Successful Response",
"content": {
"application/json": {
"schema": {}
}
}
}
}
}
}
},
"components": {
"schemas": {
"APIResponse": {
"properties": {
"success": {
"type": "boolean",
"title": "Success"
},
"message": {
"type": "string",
"title": "Message"
},
"data": {
"anyOf": [
{
"type": "object"
},
{
"type": "null"
}
],
"title": "Data"
}
},
"type": "object",
"required": [
"success",
"message"
],
"title": "APIResponse",
"example": {
"data": {},
"message": "操作成功",
"success": true
}
},
"HTTPValidationError": {
"properties": {
"detail": {
"items": {
"$ref": "#/components/schemas/ValidationError"
},
"type": "array",
"title": "Detail"
}
},
"type": "object",
"title": "HTTPValidationError"
},
"UserLogin": {
"properties": {
"username": {
"type": "string",
"title": "Username"
},
"password": {
"type": "string",
"title": "Password"
}
},
"type": "object",
"required": [
"username",
"password"
],
"title": "UserLogin",
"example": {
"password": "admin123",
"username": "admin"
}
},
"UserRegister": {
"properties": {
"username": {
"type": "string",
"title": "Username"
},
"password": {
"type": "string",
"title": "Password"
}
},
"type": "object",
"required": [
"username",
"password"
],
"title": "UserRegister",
"example": {
"password": "newpassword",
"username": "newuser"
}
},
"ValidationError": {
"properties": {
"loc": {
"items": {
"anyOf": [
{
"type": "string"
},
{
"type": "integer"
}
]
},
"type": "array",
"title": "Location"
},
"msg": {
"type": "string",
"title": "Message"
},
"type": {
"type": "string",
"title": "Error Type"
}
},
"type": "object",
"required": [
"loc",
"msg",
"type"
],
"title": "ValidationError"
}
},
"securitySchemes": {
"HTTPBearer": {
"type": "http",
"scheme": "bearer"
}
}
},
"servers": [
{
"url": "https://gitea-admin-smart-crop-x-app.dev.maimaiag.com/",
"description": "测试环境服务器"
}
]
}