266 lines
5.9 KiB
YAML
266 lines
5.9 KiB
YAML
basePath: /api
|
|
definitions:
|
|
auth.Credentials:
|
|
properties:
|
|
password:
|
|
example: change-me-123
|
|
maxLength: 72
|
|
minLength: 8
|
|
type: string
|
|
username:
|
|
example: demo
|
|
maxLength: 64
|
|
minLength: 3
|
|
type: string
|
|
required:
|
|
- password
|
|
- username
|
|
type: object
|
|
auth.LogoutRequest:
|
|
properties:
|
|
refresh_token:
|
|
type: string
|
|
type: object
|
|
auth.RefreshRequest:
|
|
properties:
|
|
refresh_token:
|
|
type: string
|
|
required:
|
|
- refresh_token
|
|
type: object
|
|
auth.UserResponse:
|
|
properties:
|
|
id:
|
|
type: integer
|
|
username:
|
|
type: string
|
|
type: object
|
|
example.HelloResponse:
|
|
properties:
|
|
message:
|
|
type: string
|
|
type: object
|
|
middlewares.TokenPair:
|
|
properties:
|
|
access_token:
|
|
type: string
|
|
expires_in:
|
|
example: 900
|
|
type: integer
|
|
refresh_token:
|
|
type: string
|
|
token_type:
|
|
example: Bearer
|
|
type: string
|
|
type: object
|
|
rest.healthData:
|
|
properties:
|
|
database:
|
|
type: string
|
|
redis:
|
|
type: string
|
|
status:
|
|
type: string
|
|
type: object
|
|
rest.systemResponse:
|
|
properties:
|
|
code:
|
|
example: 200
|
|
type: integer
|
|
data: {}
|
|
message:
|
|
type: string
|
|
type: object
|
|
utils.APIResponse:
|
|
properties:
|
|
code:
|
|
type: integer
|
|
data: {}
|
|
message:
|
|
type: string
|
|
type: object
|
|
info:
|
|
contact: {}
|
|
description: Skeleton API documentation.
|
|
title: Skeleton API
|
|
version: 0.1.0
|
|
paths:
|
|
/auth/login:
|
|
post:
|
|
consumes:
|
|
- application/json
|
|
parameters:
|
|
- description: 登录信息
|
|
in: body
|
|
name: body
|
|
required: true
|
|
schema:
|
|
$ref: '#/definitions/auth.Credentials'
|
|
produces:
|
|
- application/json
|
|
responses:
|
|
"200":
|
|
description: OK
|
|
schema:
|
|
allOf:
|
|
- $ref: '#/definitions/utils.APIResponse'
|
|
- properties:
|
|
data:
|
|
$ref: '#/definitions/middlewares.TokenPair'
|
|
type: object
|
|
"401":
|
|
description: Unauthorized
|
|
schema:
|
|
$ref: '#/definitions/utils.APIResponse'
|
|
summary: 用户登录
|
|
tags:
|
|
- auth
|
|
/auth/refresh:
|
|
post:
|
|
consumes:
|
|
- application/json
|
|
parameters:
|
|
- description: Refresh Token
|
|
in: body
|
|
name: body
|
|
required: true
|
|
schema:
|
|
$ref: '#/definitions/auth.RefreshRequest'
|
|
produces:
|
|
- application/json
|
|
responses:
|
|
"200":
|
|
description: OK
|
|
schema:
|
|
allOf:
|
|
- $ref: '#/definitions/utils.APIResponse'
|
|
- properties:
|
|
data:
|
|
$ref: '#/definitions/middlewares.TokenPair'
|
|
type: object
|
|
"401":
|
|
description: Unauthorized
|
|
schema:
|
|
$ref: '#/definitions/utils.APIResponse'
|
|
summary: 刷新并轮换 Token
|
|
tags:
|
|
- auth
|
|
/auth/register:
|
|
post:
|
|
consumes:
|
|
- application/json
|
|
parameters:
|
|
- description: 注册信息
|
|
in: body
|
|
name: body
|
|
required: true
|
|
schema:
|
|
$ref: '#/definitions/auth.Credentials'
|
|
produces:
|
|
- application/json
|
|
responses:
|
|
"201":
|
|
description: Created
|
|
schema:
|
|
allOf:
|
|
- $ref: '#/definitions/utils.APIResponse'
|
|
- properties:
|
|
data:
|
|
$ref: '#/definitions/auth.UserResponse'
|
|
type: object
|
|
"400":
|
|
description: Bad Request
|
|
schema:
|
|
$ref: '#/definitions/utils.APIResponse'
|
|
"409":
|
|
description: Conflict
|
|
schema:
|
|
$ref: '#/definitions/utils.APIResponse'
|
|
summary: 注册示例用户
|
|
tags:
|
|
- auth
|
|
/example/hello:
|
|
get:
|
|
produces:
|
|
- application/json
|
|
responses:
|
|
"200":
|
|
description: OK
|
|
schema:
|
|
allOf:
|
|
- $ref: '#/definitions/utils.APIResponse'
|
|
- properties:
|
|
data:
|
|
$ref: '#/definitions/example.HelloResponse'
|
|
type: object
|
|
summary: 返回示例消息
|
|
tags:
|
|
- example
|
|
/health:
|
|
get:
|
|
produces:
|
|
- application/json
|
|
responses:
|
|
"200":
|
|
description: OK
|
|
schema:
|
|
allOf:
|
|
- $ref: '#/definitions/rest.systemResponse'
|
|
- properties:
|
|
data:
|
|
$ref: '#/definitions/rest.healthData'
|
|
type: object
|
|
"503":
|
|
description: Service Unavailable
|
|
schema:
|
|
allOf:
|
|
- $ref: '#/definitions/rest.systemResponse'
|
|
- properties:
|
|
data:
|
|
$ref: '#/definitions/rest.healthData'
|
|
type: object
|
|
summary: 服务健康检查
|
|
tags:
|
|
- system
|
|
/ping:
|
|
get:
|
|
produces:
|
|
- application/json
|
|
responses:
|
|
"200":
|
|
description: OK
|
|
schema:
|
|
$ref: '#/definitions/rest.systemResponse'
|
|
summary: 服务连通性检查
|
|
tags:
|
|
- system
|
|
/private/auth/logout:
|
|
post:
|
|
consumes:
|
|
- application/json
|
|
parameters:
|
|
- description: 可选 Refresh Token
|
|
in: body
|
|
name: body
|
|
schema:
|
|
$ref: '#/definitions/auth.LogoutRequest'
|
|
produces:
|
|
- application/json
|
|
responses:
|
|
"200":
|
|
description: OK
|
|
schema:
|
|
$ref: '#/definitions/utils.APIResponse'
|
|
security:
|
|
- BearerAuth: []
|
|
summary: 注销并撤销 Token
|
|
tags:
|
|
- auth
|
|
securityDefinitions:
|
|
BearerAuth:
|
|
description: 输入 Bearer {token}
|
|
in: header
|
|
name: Authorization
|
|
type: apiKey
|
|
swagger: "2.0"
|