swagger
This commit is contained in:
151
docs/swagger.yaml
Normal file
151
docs/swagger.yaml
Normal file
@@ -0,0 +1,151 @@
|
||||
basePath: /api/v1
|
||||
definitions:
|
||||
controller.Response:
|
||||
properties:
|
||||
code:
|
||||
description: 业务状态码
|
||||
type: integer
|
||||
data:
|
||||
description: 业务数据
|
||||
message:
|
||||
description: 提示信息
|
||||
type: string
|
||||
type: object
|
||||
user.CreateUserRequest:
|
||||
properties:
|
||||
password:
|
||||
example: password123
|
||||
minLength: 6
|
||||
type: string
|
||||
username:
|
||||
example: newuser
|
||||
type: string
|
||||
required:
|
||||
- password
|
||||
- username
|
||||
type: object
|
||||
user.CreateUserResponse:
|
||||
properties:
|
||||
id:
|
||||
example: 1
|
||||
type: integer
|
||||
username:
|
||||
example: newuser
|
||||
type: string
|
||||
type: object
|
||||
user.LoginRequest:
|
||||
properties:
|
||||
password:
|
||||
example: password123
|
||||
type: string
|
||||
username:
|
||||
example: testuser
|
||||
type: string
|
||||
required:
|
||||
- password
|
||||
- username
|
||||
type: object
|
||||
user.LoginResponse:
|
||||
properties:
|
||||
id:
|
||||
example: 1
|
||||
type: integer
|
||||
token:
|
||||
example: eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...
|
||||
type: string
|
||||
username:
|
||||
example: testuser
|
||||
type: string
|
||||
type: object
|
||||
host: localhost:8080
|
||||
info:
|
||||
contact:
|
||||
email: divano@example.com
|
||||
name: Divano
|
||||
url: http://www.example.com
|
||||
description: 这是一个用于管理猪场设备的后端服务。
|
||||
license:
|
||||
name: Apache 2.0
|
||||
url: http://www.apache.org/licenses/LICENSE-2.0.html
|
||||
title: 猪场管理系统 API
|
||||
version: "1.0"
|
||||
paths:
|
||||
/users:
|
||||
post:
|
||||
consumes:
|
||||
- application/json
|
||||
description: 根据用户名和密码创建一个新的系统用户。
|
||||
parameters:
|
||||
- description: 用户信息
|
||||
in: body
|
||||
name: user
|
||||
required: true
|
||||
schema:
|
||||
$ref: '#/definitions/user.CreateUserRequest'
|
||||
produces:
|
||||
- application/json
|
||||
responses:
|
||||
"200":
|
||||
description: 用户创建成功
|
||||
schema:
|
||||
allOf:
|
||||
- $ref: '#/definitions/controller.Response'
|
||||
- properties:
|
||||
data:
|
||||
$ref: '#/definitions/user.CreateUserResponse'
|
||||
type: object
|
||||
"400":
|
||||
description: 请求参数错误
|
||||
schema:
|
||||
$ref: '#/definitions/controller.Response'
|
||||
"409":
|
||||
description: 用户名已存在
|
||||
schema:
|
||||
$ref: '#/definitions/controller.Response'
|
||||
"500":
|
||||
description: 服务器内部错误
|
||||
schema:
|
||||
$ref: '#/definitions/controller.Response'
|
||||
summary: 创建新用户
|
||||
tags:
|
||||
- 用户管理
|
||||
/users/login:
|
||||
post:
|
||||
consumes:
|
||||
- application/json
|
||||
description: 用户使用用户名和密码登录,成功后返回 JWT 令牌。
|
||||
parameters:
|
||||
- description: 登录凭证
|
||||
in: body
|
||||
name: credentials
|
||||
required: true
|
||||
schema:
|
||||
$ref: '#/definitions/user.LoginRequest'
|
||||
produces:
|
||||
- application/json
|
||||
responses:
|
||||
"200":
|
||||
description: 登录成功
|
||||
schema:
|
||||
allOf:
|
||||
- $ref: '#/definitions/controller.Response'
|
||||
- properties:
|
||||
data:
|
||||
$ref: '#/definitions/user.LoginResponse'
|
||||
type: object
|
||||
"400":
|
||||
description: 请求参数错误
|
||||
schema:
|
||||
$ref: '#/definitions/controller.Response'
|
||||
"401":
|
||||
description: 用户名或密码不正确
|
||||
schema:
|
||||
$ref: '#/definitions/controller.Response'
|
||||
"500":
|
||||
description: 服务器内部错误
|
||||
schema:
|
||||
$ref: '#/definitions/controller.Response'
|
||||
summary: 用户登录
|
||||
tags:
|
||||
- 用户管理
|
||||
swagger: "2.0"
|
||||
Reference in New Issue
Block a user