603 lines
21 KiB
JSON
603 lines
21 KiB
JSON
{
|
|
"openapi": "3.0.2",
|
|
"info": {
|
|
"title": "User Management System",
|
|
"description": "API for managing users with role-based access control",
|
|
"version": "1.0.0"
|
|
},
|
|
"paths": {
|
|
"/api/auth/login": {
|
|
"post": {
|
|
"tags": [
|
|
"auth",
|
|
"auth"
|
|
],
|
|
"summary": "Login",
|
|
"operationId": "login_api_auth_login_post",
|
|
"requestBody": {
|
|
"content": {
|
|
"application/json": {
|
|
"schema": {
|
|
"$ref": "#/components/schemas/LoginRequest"
|
|
}
|
|
}
|
|
},
|
|
"required": true
|
|
},
|
|
"responses": {
|
|
"200": {
|
|
"description": "Successful Response",
|
|
"content": {
|
|
"application/json": {
|
|
"schema": {
|
|
"$ref": "#/components/schemas/TokenResponse"
|
|
}
|
|
}
|
|
}
|
|
},
|
|
"422": {
|
|
"description": "Validation Error",
|
|
"content": {
|
|
"application/json": {
|
|
"schema": {
|
|
"$ref": "#/components/schemas/HTTPValidationError"
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
},
|
|
"/api/auth/refresh": {
|
|
"post": {
|
|
"tags": [
|
|
"auth",
|
|
"auth"
|
|
],
|
|
"summary": "Refresh Token",
|
|
"operationId": "refresh_token_api_auth_refresh_post",
|
|
"requestBody": {
|
|
"content": {
|
|
"application/json": {
|
|
"schema": {
|
|
"$ref": "#/components/schemas/RefreshTokenRequest"
|
|
}
|
|
}
|
|
},
|
|
"required": true
|
|
},
|
|
"responses": {
|
|
"200": {
|
|
"description": "Successful Response",
|
|
"content": {
|
|
"application/json": {
|
|
"schema": {
|
|
"$ref": "#/components/schemas/TokenResponse"
|
|
}
|
|
}
|
|
}
|
|
},
|
|
"422": {
|
|
"description": "Validation Error",
|
|
"content": {
|
|
"application/json": {
|
|
"schema": {
|
|
"$ref": "#/components/schemas/HTTPValidationError"
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
},
|
|
"/api/users/": {
|
|
"get": {
|
|
"tags": [
|
|
"users",
|
|
"users"
|
|
],
|
|
"summary": "Get Users List",
|
|
"operationId": "get_users_list_api_users__get",
|
|
"parameters": [
|
|
{
|
|
"required": false,
|
|
"schema": {
|
|
"title": "Page",
|
|
"type": "integer",
|
|
"default": 1
|
|
},
|
|
"name": "page",
|
|
"in": "query"
|
|
},
|
|
{
|
|
"required": false,
|
|
"schema": {
|
|
"title": "Limit",
|
|
"type": "integer",
|
|
"default": 100
|
|
},
|
|
"name": "limit",
|
|
"in": "query"
|
|
},
|
|
{
|
|
"required": false,
|
|
"schema": {
|
|
"title": "Role",
|
|
"type": "string"
|
|
},
|
|
"name": "role",
|
|
"in": "query"
|
|
}
|
|
],
|
|
"responses": {
|
|
"200": {
|
|
"description": "Successful Response",
|
|
"content": {
|
|
"application/json": {
|
|
"schema": {
|
|
"title": "Response Get Users List Api Users Get",
|
|
"type": "array",
|
|
"items": {
|
|
"$ref": "#/components/schemas/UserResponse"
|
|
}
|
|
}
|
|
}
|
|
}
|
|
},
|
|
"422": {
|
|
"description": "Validation Error",
|
|
"content": {
|
|
"application/json": {
|
|
"schema": {
|
|
"$ref": "#/components/schemas/HTTPValidationError"
|
|
}
|
|
}
|
|
}
|
|
}
|
|
},
|
|
"security": [
|
|
{
|
|
"OAuth2PasswordBearer": []
|
|
}
|
|
]
|
|
},
|
|
"post": {
|
|
"tags": [
|
|
"users",
|
|
"users"
|
|
],
|
|
"summary": "Create User",
|
|
"operationId": "create_user_api_users__post",
|
|
"requestBody": {
|
|
"content": {
|
|
"application/json": {
|
|
"schema": {
|
|
"$ref": "#/components/schemas/UserCreate"
|
|
}
|
|
}
|
|
},
|
|
"required": true
|
|
},
|
|
"responses": {
|
|
"201": {
|
|
"description": "Successful Response",
|
|
"content": {
|
|
"application/json": {
|
|
"schema": {
|
|
"$ref": "#/components/schemas/UserResponse"
|
|
}
|
|
}
|
|
}
|
|
},
|
|
"422": {
|
|
"description": "Validation Error",
|
|
"content": {
|
|
"application/json": {
|
|
"schema": {
|
|
"$ref": "#/components/schemas/HTTPValidationError"
|
|
}
|
|
}
|
|
}
|
|
}
|
|
},
|
|
"security": [
|
|
{
|
|
"OAuth2PasswordBearer": []
|
|
}
|
|
]
|
|
}
|
|
},
|
|
"/api/users/{user_id}": {
|
|
"get": {
|
|
"tags": [
|
|
"users",
|
|
"users"
|
|
],
|
|
"summary": "Get User",
|
|
"operationId": "get_user_api_users__user_id__get",
|
|
"parameters": [
|
|
{
|
|
"required": true,
|
|
"schema": {
|
|
"title": "User Id",
|
|
"type": "integer"
|
|
},
|
|
"name": "user_id",
|
|
"in": "path"
|
|
}
|
|
],
|
|
"responses": {
|
|
"200": {
|
|
"description": "Successful Response",
|
|
"content": {
|
|
"application/json": {
|
|
"schema": {
|
|
"$ref": "#/components/schemas/UserResponse"
|
|
}
|
|
}
|
|
}
|
|
},
|
|
"422": {
|
|
"description": "Validation Error",
|
|
"content": {
|
|
"application/json": {
|
|
"schema": {
|
|
"$ref": "#/components/schemas/HTTPValidationError"
|
|
}
|
|
}
|
|
}
|
|
}
|
|
},
|
|
"security": [
|
|
{
|
|
"OAuth2PasswordBearer": []
|
|
}
|
|
]
|
|
},
|
|
"put": {
|
|
"tags": [
|
|
"users",
|
|
"users"
|
|
],
|
|
"summary": "Update User",
|
|
"operationId": "update_user_api_users__user_id__put",
|
|
"parameters": [
|
|
{
|
|
"required": true,
|
|
"schema": {
|
|
"title": "User Id",
|
|
"type": "integer"
|
|
},
|
|
"name": "user_id",
|
|
"in": "path"
|
|
}
|
|
],
|
|
"requestBody": {
|
|
"content": {
|
|
"application/json": {
|
|
"schema": {
|
|
"$ref": "#/components/schemas/UserUpdate"
|
|
}
|
|
}
|
|
},
|
|
"required": true
|
|
},
|
|
"responses": {
|
|
"200": {
|
|
"description": "Successful Response",
|
|
"content": {
|
|
"application/json": {
|
|
"schema": {
|
|
"$ref": "#/components/schemas/UserResponse"
|
|
}
|
|
}
|
|
}
|
|
},
|
|
"422": {
|
|
"description": "Validation Error",
|
|
"content": {
|
|
"application/json": {
|
|
"schema": {
|
|
"$ref": "#/components/schemas/HTTPValidationError"
|
|
}
|
|
}
|
|
}
|
|
}
|
|
},
|
|
"security": [
|
|
{
|
|
"OAuth2PasswordBearer": []
|
|
}
|
|
]
|
|
},
|
|
"delete": {
|
|
"tags": [
|
|
"users",
|
|
"users"
|
|
],
|
|
"summary": "Delete User",
|
|
"operationId": "delete_user_api_users__user_id__delete",
|
|
"parameters": [
|
|
{
|
|
"required": true,
|
|
"schema": {
|
|
"title": "User Id",
|
|
"type": "integer"
|
|
},
|
|
"name": "user_id",
|
|
"in": "path"
|
|
}
|
|
],
|
|
"responses": {
|
|
"204": {
|
|
"description": "Successful Response"
|
|
},
|
|
"422": {
|
|
"description": "Validation Error",
|
|
"content": {
|
|
"application/json": {
|
|
"schema": {
|
|
"$ref": "#/components/schemas/HTTPValidationError"
|
|
}
|
|
}
|
|
}
|
|
}
|
|
},
|
|
"security": [
|
|
{
|
|
"OAuth2PasswordBearer": []
|
|
}
|
|
]
|
|
}
|
|
}
|
|
},
|
|
"components": {
|
|
"schemas": {
|
|
"HTTPValidationError": {
|
|
"title": "HTTPValidationError",
|
|
"type": "object",
|
|
"properties": {
|
|
"detail": {
|
|
"title": "Detail",
|
|
"type": "array",
|
|
"items": {
|
|
"$ref": "#/components/schemas/ValidationError"
|
|
}
|
|
}
|
|
}
|
|
},
|
|
"LoginRequest": {
|
|
"title": "LoginRequest",
|
|
"required": [
|
|
"username",
|
|
"password"
|
|
],
|
|
"type": "object",
|
|
"properties": {
|
|
"username": {
|
|
"title": "Username",
|
|
"type": "string"
|
|
},
|
|
"password": {
|
|
"title": "Password",
|
|
"type": "string"
|
|
}
|
|
}
|
|
},
|
|
"RefreshTokenRequest": {
|
|
"title": "RefreshTokenRequest",
|
|
"required": [
|
|
"refresh_token"
|
|
],
|
|
"type": "object",
|
|
"properties": {
|
|
"refresh_token": {
|
|
"title": "Refresh Token",
|
|
"type": "string"
|
|
}
|
|
}
|
|
},
|
|
"TokenResponse": {
|
|
"title": "TokenResponse",
|
|
"required": [
|
|
"access_token",
|
|
"refresh_token",
|
|
"token_type",
|
|
"access_token_exp",
|
|
"refresh_token_exp"
|
|
],
|
|
"type": "object",
|
|
"properties": {
|
|
"access_token": {
|
|
"title": "Access Token",
|
|
"type": "string"
|
|
},
|
|
"refresh_token": {
|
|
"title": "Refresh Token",
|
|
"type": "string"
|
|
},
|
|
"token_type": {
|
|
"title": "Token Type",
|
|
"type": "string"
|
|
},
|
|
"access_token_exp": {
|
|
"title": "Access Token Exp",
|
|
"type": "integer"
|
|
},
|
|
"refresh_token_exp": {
|
|
"title": "Refresh Token Exp",
|
|
"type": "integer"
|
|
}
|
|
}
|
|
},
|
|
"UserCreate": {
|
|
"title": "UserCreate",
|
|
"required": [
|
|
"username",
|
|
"password"
|
|
],
|
|
"type": "object",
|
|
"properties": {
|
|
"username": {
|
|
"title": "Username",
|
|
"maxLength": 50,
|
|
"type": "string",
|
|
"description": "用户名"
|
|
},
|
|
"role": {
|
|
"allOf": [
|
|
{
|
|
"$ref": "#/components/schemas/UserRole"
|
|
}
|
|
],
|
|
"description": "用户角色",
|
|
"default": "user"
|
|
},
|
|
"description": {
|
|
"title": "Description",
|
|
"maxLength": 255,
|
|
"type": "string",
|
|
"description": "用户描述"
|
|
},
|
|
"password": {
|
|
"title": "Password",
|
|
"maxLength": 255,
|
|
"minLength": 6,
|
|
"type": "string",
|
|
"description": "用户密码"
|
|
}
|
|
}
|
|
},
|
|
"UserResponse": {
|
|
"title": "UserResponse",
|
|
"required": [
|
|
"username",
|
|
"id",
|
|
"created_at",
|
|
"updated_at"
|
|
],
|
|
"type": "object",
|
|
"properties": {
|
|
"username": {
|
|
"title": "Username",
|
|
"maxLength": 50,
|
|
"type": "string",
|
|
"description": "用户名"
|
|
},
|
|
"role": {
|
|
"allOf": [
|
|
{
|
|
"$ref": "#/components/schemas/UserRole"
|
|
}
|
|
],
|
|
"description": "用户角色",
|
|
"default": "user"
|
|
},
|
|
"description": {
|
|
"title": "Description",
|
|
"maxLength": 255,
|
|
"type": "string",
|
|
"description": "用户描述"
|
|
},
|
|
"id": {
|
|
"title": "Id",
|
|
"type": "integer",
|
|
"description": "用户ID"
|
|
},
|
|
"created_at": {
|
|
"title": "Created At",
|
|
"type": "string",
|
|
"description": "创建时间",
|
|
"format": "date-time"
|
|
},
|
|
"updated_at": {
|
|
"title": "Updated At",
|
|
"type": "string",
|
|
"description": "更新时间",
|
|
"format": "date-time"
|
|
}
|
|
}
|
|
},
|
|
"UserRole": {
|
|
"title": "UserRole",
|
|
"enum": [
|
|
"system_admin",
|
|
"admin",
|
|
"user"
|
|
],
|
|
"type": "string",
|
|
"description": "An enumeration."
|
|
},
|
|
"UserUpdate": {
|
|
"title": "UserUpdate",
|
|
"type": "object",
|
|
"properties": {
|
|
"username": {
|
|
"title": "Username",
|
|
"maxLength": 50,
|
|
"type": "string",
|
|
"description": "用户名"
|
|
},
|
|
"role": {
|
|
"allOf": [
|
|
{
|
|
"$ref": "#/components/schemas/UserRole"
|
|
}
|
|
],
|
|
"description": "用户角色"
|
|
},
|
|
"description": {
|
|
"title": "Description",
|
|
"maxLength": 255,
|
|
"type": "string",
|
|
"description": "用户描述"
|
|
}
|
|
}
|
|
},
|
|
"ValidationError": {
|
|
"title": "ValidationError",
|
|
"required": [
|
|
"loc",
|
|
"msg",
|
|
"type"
|
|
],
|
|
"type": "object",
|
|
"properties": {
|
|
"loc": {
|
|
"title": "Location",
|
|
"type": "array",
|
|
"items": {
|
|
"anyOf": [
|
|
{
|
|
"type": "string"
|
|
},
|
|
{
|
|
"type": "integer"
|
|
}
|
|
]
|
|
}
|
|
},
|
|
"msg": {
|
|
"title": "Message",
|
|
"type": "string"
|
|
},
|
|
"type": {
|
|
"title": "Error Type",
|
|
"type": "string"
|
|
}
|
|
}
|
|
}
|
|
},
|
|
"securitySchemes": {
|
|
"OAuth2PasswordBearer": {
|
|
"type": "oauth2",
|
|
"flows": {
|
|
"password": {
|
|
"scopes": {},
|
|
"tokenUrl": "auth/login"
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
} |