Files
niumalll/docs/api/users.yaml

229 lines
5.8 KiB
YAML

openapi: 3.0.0
info:
title: 用户管理API
description: 用户管理相关接口文档
version: 1.0.0
paths:
/api/users/:
get:
summary: 获取用户列表
description: 获取系统中的用户列表,支持分页
parameters:
- name: skip
in: query
description: 跳过的记录数
required: false
schema:
type: integer
default: 0
- name: limit
in: query
description: 返回的记录数
required: false
schema:
type: integer
default: 100
responses:
'200':
description: 成功返回用户列表
content:
application/json:
schema:
type: array
items:
$ref: '#/components/schemas/User'
'401':
description: 未授权
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
'500':
description: 服务器内部错误
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
/api/users/{user_id}:
get:
summary: 获取用户详情
description: 根据用户ID获取用户详细信息
parameters:
- name: user_id
in: path
description: 用户ID
required: true
schema:
type: integer
responses:
'200':
description: 成功返回用户信息
content:
application/json:
schema:
$ref: '#/components/schemas/User'
'404':
description: 用户未找到
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
'401':
description: 未授权
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
'500':
description: 服务器内部错误
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
put:
summary: 更新用户信息
description: 根据用户ID更新用户信息
parameters:
- name: user_id
in: path
description: 用户ID
required: true
schema:
type: integer
requestBody:
required: true
content:
application/json:
schema:
$ref: '#/components/schemas/UserUpdate'
responses:
'200':
description: 成功更新用户信息
content:
application/json:
schema:
$ref: '#/components/schemas/User'
'404':
description: 用户未找到
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
'401':
description: 未授权
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
'422':
description: 请求参数验证失败
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
'500':
description: 服务器内部错误
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
delete:
summary: 删除用户
description: 根据用户ID删除用户
parameters:
- name: user_id
in: path
description: 用户ID
required: true
schema:
type: integer
responses:
'200':
description: 成功删除用户
content:
application/json:
schema:
$ref: '#/components/schemas/User'
'404':
description: 用户未找到
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
'401':
description: 未授权
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
'500':
description: 服务器内部错误
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
components:
schemas:
User:
type: object
properties:
id:
type: integer
description: 用户ID
uuid:
type: string
description: 用户UUID
username:
type: string
description: 用户名
user_type:
type: string
enum: [client, supplier, driver, staff, admin]
description: 用户类型
status:
type: string
enum: [active, inactive, locked]
description: 用户状态
created_at:
type: string
format: date-time
description: 创建时间
updated_at:
type: string
format: date-time
description: 更新时间
required:
- id
- uuid
- username
- user_type
- status
- created_at
- updated_at
UserUpdate:
type: object
properties:
username:
type: string
description: 用户名
user_type:
type: string
enum: [client, supplier, driver, staff, admin]
description: 用户类型
status:
type: string
enum: [active, inactive, locked]
description: 用户状态
Error:
type: object
properties:
detail:
type: string
description: 错误信息
required:
- detail