115 lines
2.7 KiB
YAML
115 lines
2.7 KiB
YAML
register:
|
|
post:
|
|
tags:
|
|
- auth
|
|
summary: 用户注册
|
|
operationId: register
|
|
security: [] # 注册接口不需要认证
|
|
requestBody:
|
|
required: true
|
|
content:
|
|
application/json:
|
|
schema:
|
|
type: object
|
|
required:
|
|
- username
|
|
- email
|
|
- password
|
|
- role
|
|
properties:
|
|
username:
|
|
type: string
|
|
minLength: 3
|
|
maxLength: 32
|
|
email:
|
|
type: string
|
|
format: email
|
|
password:
|
|
type: string
|
|
format: password
|
|
minLength: 8
|
|
role:
|
|
type: string
|
|
enum:
|
|
- admin
|
|
- editor
|
|
- contributor
|
|
responses:
|
|
'200':
|
|
description: 注册成功
|
|
content:
|
|
application/json:
|
|
schema:
|
|
type: object
|
|
required:
|
|
- token
|
|
- user
|
|
properties:
|
|
token:
|
|
type: string
|
|
user:
|
|
$ref: '../components/schemas.yaml#/User'
|
|
'400':
|
|
description: 用户名已存在
|
|
content:
|
|
application/json:
|
|
schema:
|
|
$ref: '../components/schemas.yaml#/Error'
|
|
'422':
|
|
$ref: '../components/responses.yaml#/ValidationError'
|
|
|
|
login:
|
|
post:
|
|
tags:
|
|
- auth
|
|
summary: 用户登录
|
|
operationId: login
|
|
security: [] # 登录接口不需要认证
|
|
requestBody:
|
|
required: true
|
|
content:
|
|
application/json:
|
|
schema:
|
|
type: object
|
|
required:
|
|
- username
|
|
- password
|
|
properties:
|
|
username:
|
|
type: string
|
|
minLength: 3
|
|
maxLength: 32
|
|
password:
|
|
type: string
|
|
format: password
|
|
responses:
|
|
'200':
|
|
description: 登录成功
|
|
content:
|
|
application/json:
|
|
schema:
|
|
type: object
|
|
required:
|
|
- token
|
|
- user
|
|
properties:
|
|
token:
|
|
type: string
|
|
user:
|
|
$ref: '../components/schemas.yaml#/User'
|
|
'401':
|
|
$ref: '../components/responses.yaml#/Unauthorized'
|
|
'422':
|
|
$ref: '../components/responses.yaml#/ValidationError'
|
|
|
|
logout:
|
|
post:
|
|
tags:
|
|
- auth
|
|
summary: 用户登出
|
|
operationId: logout
|
|
responses:
|
|
'204':
|
|
description: 登出成功
|
|
'401':
|
|
$ref: '../components/responses.yaml#/Unauthorized'
|