修复swagger

This commit is contained in:
2025-09-19 23:51:13 +08:00
parent 88e0fbfb64
commit cb63437e0e
8 changed files with 446 additions and 94 deletions

View File

@@ -27,9 +27,24 @@ const docTemplate = `{
"summary": "获取设备列表",
"responses": {
"200": {
"description": "业务失败,具体错误码和信息见响应体",
"description": "OK",
"schema": {
"$ref": "#/definitions/controller.Response"
"allOf": [
{
"$ref": "#/definitions/controller.Response"
},
{
"type": "object",
"properties": {
"data": {
"type": "array",
"items": {
"$ref": "#/definitions/git_huangwc_com_pig_pig-farm-controller_internal_app_controller_device.DeviceResponse"
}
}
}
}
]
}
}
}
@@ -59,9 +74,21 @@ const docTemplate = `{
],
"responses": {
"200": {
"description": "业务失败,具体错误码和信息见响应体",
"description": "OK",
"schema": {
"$ref": "#/definitions/controller.Response"
"allOf": [
{
"$ref": "#/definitions/controller.Response"
},
{
"type": "object",
"properties": {
"data": {
"$ref": "#/definitions/git_huangwc_com_pig_pig-farm-controller_internal_app_controller_device.DeviceResponse"
}
}
}
]
}
}
}
@@ -88,9 +115,21 @@ const docTemplate = `{
],
"responses": {
"200": {
"description": "业务失败,具体错误码和信息见响应体",
"description": "OK",
"schema": {
"$ref": "#/definitions/controller.Response"
"allOf": [
{
"$ref": "#/definitions/controller.Response"
},
{
"type": "object",
"properties": {
"data": {
"$ref": "#/definitions/git_huangwc_com_pig_pig-farm-controller_internal_app_controller_device.DeviceResponse"
}
}
}
]
}
}
}
@@ -127,9 +166,21 @@ const docTemplate = `{
],
"responses": {
"200": {
"description": "业务失败,具体错误码和信息见响应体",
"description": "OK",
"schema": {
"$ref": "#/definitions/controller.Response"
"allOf": [
{
"$ref": "#/definitions/controller.Response"
},
{
"type": "object",
"properties": {
"data": {
"$ref": "#/definitions/git_huangwc_com_pig_pig-farm-controller_internal_app_controller_device.DeviceResponse"
}
}
}
]
}
}
}
@@ -154,7 +205,7 @@ const docTemplate = `{
],
"responses": {
"200": {
"description": "业务失败,具体错误码和信息见响应体",
"description": "OK",
"schema": {
"$ref": "#/definitions/controller.Response"
}
@@ -174,9 +225,21 @@ const docTemplate = `{
"summary": "获取计划列表",
"responses": {
"200": {
"description": "业务失败具体错误码和信息见响应体例如400, 500",
"description": "业务码为200代表成功获取列表",
"schema": {
"$ref": "#/definitions/controller.Response"
"allOf": [
{
"$ref": "#/definitions/controller.Response"
},
{
"type": "object",
"properties": {
"data": {
"$ref": "#/definitions/plan.ListPlansResponse"
}
}
}
]
}
}
}
@@ -206,9 +269,21 @@ const docTemplate = `{
],
"responses": {
"200": {
"description": "业务失败具体错误码和信息见响应体例如400, 500",
"description": "业务码为201代表创建成功",
"schema": {
"$ref": "#/definitions/controller.Response"
"allOf": [
{
"$ref": "#/definitions/controller.Response"
},
{
"type": "object",
"properties": {
"data": {
"$ref": "#/definitions/plan.PlanResponse"
}
}
}
]
}
}
}
@@ -235,9 +310,21 @@ const docTemplate = `{
],
"responses": {
"200": {
"description": "业务失败具体错误码和信息见响应体例如400, 404, 500",
"description": "业务码为200代表成功获取",
"schema": {
"$ref": "#/definitions/controller.Response"
"allOf": [
{
"$ref": "#/definitions/controller.Response"
},
{
"type": "object",
"properties": {
"data": {
"$ref": "#/definitions/plan.PlanResponse"
}
}
}
]
}
}
}
@@ -274,9 +361,21 @@ const docTemplate = `{
],
"responses": {
"200": {
"description": "业务失败具体错误码和信息见响应体例如400, 404, 500",
"description": "业务码为200代表更新成功",
"schema": {
"$ref": "#/definitions/controller.Response"
"allOf": [
{
"$ref": "#/definitions/controller.Response"
},
{
"type": "object",
"properties": {
"data": {
"$ref": "#/definitions/plan.PlanResponse"
}
}
}
]
}
}
}
@@ -301,7 +400,7 @@ const docTemplate = `{
],
"responses": {
"200": {
"description": "业务失败具体错误码和信息见响应体例如400, 404, 500",
"description": "业务码为200代表删除成功",
"schema": {
"$ref": "#/definitions/controller.Response"
}
@@ -330,7 +429,7 @@ const docTemplate = `{
],
"responses": {
"200": {
"description": "业务失败具体错误码和信息见响应体例如400, 404, 500",
"description": "业务码为200代表成功启动计划",
"schema": {
"$ref": "#/definitions/controller.Response"
}
@@ -359,7 +458,7 @@ const docTemplate = `{
],
"responses": {
"200": {
"description": "业务失败具体错误码和信息见响应体例如400, 404, 500",
"description": "业务码为200代表成功停止计划",
"schema": {
"$ref": "#/definitions/controller.Response"
}
@@ -393,9 +492,21 @@ const docTemplate = `{
],
"responses": {
"200": {
"description": "业务失败具体错误码和信息见响应体例如400, 409, 500",
"description": "业务码为201代表创建成功",
"schema": {
"$ref": "#/definitions/controller.Response"
"allOf": [
{
"$ref": "#/definitions/controller.Response"
},
{
"type": "object",
"properties": {
"data": {
"$ref": "#/definitions/user.CreateUserResponse"
}
}
}
]
}
}
}
@@ -427,9 +538,21 @@ const docTemplate = `{
],
"responses": {
"200": {
"description": "业务失败具体错误码和信息见响应体例如400, 401, 500",
"description": "业务码为200代表登录成功",
"schema": {
"$ref": "#/definitions/controller.Response"
"allOf": [
{
"$ref": "#/definitions/controller.Response"
},
{
"type": "object",
"properties": {
"data": {
"$ref": "#/definitions/user.LoginResponse"
}
}
}
]
}
}
}
@@ -457,7 +580,31 @@ const docTemplate = `{
}
},
"device.CreateDeviceRequest": {
"type": "object"
"type": "object",
"required": [
"name",
"type"
],
"properties": {
"location": {
"type": "string"
},
"name": {
"type": "string"
},
"parent_id": {
"type": "integer"
},
"properties": {
"$ref": "#/definitions/controller.Properties"
},
"sub_type": {
"$ref": "#/definitions/models.DeviceSubType"
},
"type": {
"$ref": "#/definitions/models.DeviceType"
}
}
},
"device.UpdateDeviceRequest": {
"type": "object",

View File

@@ -16,9 +16,24 @@
"summary": "获取设备列表",
"responses": {
"200": {
"description": "业务失败,具体错误码和信息见响应体",
"description": "OK",
"schema": {
"$ref": "#/definitions/controller.Response"
"allOf": [
{
"$ref": "#/definitions/controller.Response"
},
{
"type": "object",
"properties": {
"data": {
"type": "array",
"items": {
"$ref": "#/definitions/git_huangwc_com_pig_pig-farm-controller_internal_app_controller_device.DeviceResponse"
}
}
}
}
]
}
}
}
@@ -48,9 +63,21 @@
],
"responses": {
"200": {
"description": "业务失败,具体错误码和信息见响应体",
"description": "OK",
"schema": {
"$ref": "#/definitions/controller.Response"
"allOf": [
{
"$ref": "#/definitions/controller.Response"
},
{
"type": "object",
"properties": {
"data": {
"$ref": "#/definitions/git_huangwc_com_pig_pig-farm-controller_internal_app_controller_device.DeviceResponse"
}
}
}
]
}
}
}
@@ -77,9 +104,21 @@
],
"responses": {
"200": {
"description": "业务失败,具体错误码和信息见响应体",
"description": "OK",
"schema": {
"$ref": "#/definitions/controller.Response"
"allOf": [
{
"$ref": "#/definitions/controller.Response"
},
{
"type": "object",
"properties": {
"data": {
"$ref": "#/definitions/git_huangwc_com_pig_pig-farm-controller_internal_app_controller_device.DeviceResponse"
}
}
}
]
}
}
}
@@ -116,9 +155,21 @@
],
"responses": {
"200": {
"description": "业务失败,具体错误码和信息见响应体",
"description": "OK",
"schema": {
"$ref": "#/definitions/controller.Response"
"allOf": [
{
"$ref": "#/definitions/controller.Response"
},
{
"type": "object",
"properties": {
"data": {
"$ref": "#/definitions/git_huangwc_com_pig_pig-farm-controller_internal_app_controller_device.DeviceResponse"
}
}
}
]
}
}
}
@@ -143,7 +194,7 @@
],
"responses": {
"200": {
"description": "业务失败,具体错误码和信息见响应体",
"description": "OK",
"schema": {
"$ref": "#/definitions/controller.Response"
}
@@ -163,9 +214,21 @@
"summary": "获取计划列表",
"responses": {
"200": {
"description": "业务失败具体错误码和信息见响应体例如400, 500",
"description": "业务码为200代表成功获取列表",
"schema": {
"$ref": "#/definitions/controller.Response"
"allOf": [
{
"$ref": "#/definitions/controller.Response"
},
{
"type": "object",
"properties": {
"data": {
"$ref": "#/definitions/plan.ListPlansResponse"
}
}
}
]
}
}
}
@@ -195,9 +258,21 @@
],
"responses": {
"200": {
"description": "业务失败具体错误码和信息见响应体例如400, 500",
"description": "业务码为201代表创建成功",
"schema": {
"$ref": "#/definitions/controller.Response"
"allOf": [
{
"$ref": "#/definitions/controller.Response"
},
{
"type": "object",
"properties": {
"data": {
"$ref": "#/definitions/plan.PlanResponse"
}
}
}
]
}
}
}
@@ -224,9 +299,21 @@
],
"responses": {
"200": {
"description": "业务失败具体错误码和信息见响应体例如400, 404, 500",
"description": "业务码为200代表成功获取",
"schema": {
"$ref": "#/definitions/controller.Response"
"allOf": [
{
"$ref": "#/definitions/controller.Response"
},
{
"type": "object",
"properties": {
"data": {
"$ref": "#/definitions/plan.PlanResponse"
}
}
}
]
}
}
}
@@ -263,9 +350,21 @@
],
"responses": {
"200": {
"description": "业务失败具体错误码和信息见响应体例如400, 404, 500",
"description": "业务码为200代表更新成功",
"schema": {
"$ref": "#/definitions/controller.Response"
"allOf": [
{
"$ref": "#/definitions/controller.Response"
},
{
"type": "object",
"properties": {
"data": {
"$ref": "#/definitions/plan.PlanResponse"
}
}
}
]
}
}
}
@@ -290,7 +389,7 @@
],
"responses": {
"200": {
"description": "业务失败具体错误码和信息见响应体例如400, 404, 500",
"description": "业务码为200代表删除成功",
"schema": {
"$ref": "#/definitions/controller.Response"
}
@@ -319,7 +418,7 @@
],
"responses": {
"200": {
"description": "业务失败具体错误码和信息见响应体例如400, 404, 500",
"description": "业务码为200代表成功启动计划",
"schema": {
"$ref": "#/definitions/controller.Response"
}
@@ -348,7 +447,7 @@
],
"responses": {
"200": {
"description": "业务失败具体错误码和信息见响应体例如400, 404, 500",
"description": "业务码为200代表成功停止计划",
"schema": {
"$ref": "#/definitions/controller.Response"
}
@@ -382,9 +481,21 @@
],
"responses": {
"200": {
"description": "业务失败具体错误码和信息见响应体例如400, 409, 500",
"description": "业务码为201代表创建成功",
"schema": {
"$ref": "#/definitions/controller.Response"
"allOf": [
{
"$ref": "#/definitions/controller.Response"
},
{
"type": "object",
"properties": {
"data": {
"$ref": "#/definitions/user.CreateUserResponse"
}
}
}
]
}
}
}
@@ -416,9 +527,21 @@
],
"responses": {
"200": {
"description": "业务失败具体错误码和信息见响应体例如400, 401, 500",
"description": "业务码为200代表登录成功",
"schema": {
"$ref": "#/definitions/controller.Response"
"allOf": [
{
"$ref": "#/definitions/controller.Response"
},
{
"type": "object",
"properties": {
"data": {
"$ref": "#/definitions/user.LoginResponse"
}
}
}
]
}
}
}
@@ -446,7 +569,31 @@
}
},
"device.CreateDeviceRequest": {
"type": "object"
"type": "object",
"required": [
"name",
"type"
],
"properties": {
"location": {
"type": "string"
},
"name": {
"type": "string"
},
"parent_id": {
"type": "integer"
},
"properties": {
"$ref": "#/definitions/controller.Properties"
},
"sub_type": {
"$ref": "#/definitions/models.DeviceSubType"
},
"type": {
"$ref": "#/definitions/models.DeviceType"
}
}
},
"device.UpdateDeviceRequest": {
"type": "object",

View File

@@ -13,6 +13,22 @@ definitions:
type: string
type: object
device.CreateDeviceRequest:
properties:
location:
type: string
name:
type: string
parent_id:
type: integer
properties:
$ref: '#/definitions/controller.Properties'
sub_type:
$ref: '#/definitions/models.DeviceSubType'
type:
$ref: '#/definitions/models.DeviceType'
required:
- name
- type
type: object
device.UpdateDeviceRequest:
properties:
@@ -372,9 +388,16 @@ paths:
- application/json
responses:
"200":
description: 业务失败,具体错误码和信息见响应体
description: OK
schema:
$ref: '#/definitions/controller.Response'
allOf:
- $ref: '#/definitions/controller.Response'
- properties:
data:
items:
$ref: '#/definitions/git_huangwc_com_pig_pig-farm-controller_internal_app_controller_device.DeviceResponse'
type: array
type: object
summary: 获取设备列表
tags:
- 设备管理
@@ -393,9 +416,14 @@ paths:
- application/json
responses:
"200":
description: 业务失败,具体错误码和信息见响应体
description: OK
schema:
$ref: '#/definitions/controller.Response'
allOf:
- $ref: '#/definitions/controller.Response'
- properties:
data:
$ref: '#/definitions/git_huangwc_com_pig_pig-farm-controller_internal_app_controller_device.DeviceResponse'
type: object
summary: 创建新设备
tags:
- 设备管理
@@ -412,7 +440,7 @@ paths:
- application/json
responses:
"200":
description: 业务失败,具体错误码和信息见响应体
description: OK
schema:
$ref: '#/definitions/controller.Response'
summary: 删除设备
@@ -430,9 +458,14 @@ paths:
- application/json
responses:
"200":
description: 业务失败,具体错误码和信息见响应体
description: OK
schema:
$ref: '#/definitions/controller.Response'
allOf:
- $ref: '#/definitions/controller.Response'
- properties:
data:
$ref: '#/definitions/git_huangwc_com_pig_pig-farm-controller_internal_app_controller_device.DeviceResponse'
type: object
summary: 获取设备信息
tags:
- 设备管理
@@ -456,9 +489,14 @@ paths:
- application/json
responses:
"200":
description: 业务失败,具体错误码和信息见响应体
description: OK
schema:
$ref: '#/definitions/controller.Response'
allOf:
- $ref: '#/definitions/controller.Response'
- properties:
data:
$ref: '#/definitions/git_huangwc_com_pig_pig-farm-controller_internal_app_controller_device.DeviceResponse'
type: object
summary: 更新设备信息
tags:
- 设备管理
@@ -469,9 +507,14 @@ paths:
- application/json
responses:
"200":
description: 业务失败具体错误码和信息见响应体例如400, 500
description: 业务码为200代表成功获取列表
schema:
$ref: '#/definitions/controller.Response'
allOf:
- $ref: '#/definitions/controller.Response'
- properties:
data:
$ref: '#/definitions/plan.ListPlansResponse'
type: object
summary: 获取计划列表
tags:
- 计划管理
@@ -490,9 +533,14 @@ paths:
- application/json
responses:
"200":
description: 业务失败具体错误码和信息见响应体例如400, 500
description: 业务码为201代表创建成功
schema:
$ref: '#/definitions/controller.Response'
allOf:
- $ref: '#/definitions/controller.Response'
- properties:
data:
$ref: '#/definitions/plan.PlanResponse'
type: object
summary: 创建计划
tags:
- 计划管理
@@ -509,7 +557,7 @@ paths:
- application/json
responses:
"200":
description: 业务失败具体错误码和信息见响应体例如400, 404, 500
description: 业务码为200代表删除成功
schema:
$ref: '#/definitions/controller.Response'
summary: 删除计划
@@ -527,9 +575,14 @@ paths:
- application/json
responses:
"200":
description: 业务失败具体错误码和信息见响应体例如400, 404, 500
description: 业务码为200代表成功获取
schema:
$ref: '#/definitions/controller.Response'
allOf:
- $ref: '#/definitions/controller.Response'
- properties:
data:
$ref: '#/definitions/plan.PlanResponse'
type: object
summary: 获取计划详情
tags:
- 计划管理
@@ -553,9 +606,14 @@ paths:
- application/json
responses:
"200":
description: 业务失败具体错误码和信息见响应体例如400, 404, 500
description: 业务码为200代表更新成功
schema:
$ref: '#/definitions/controller.Response'
allOf:
- $ref: '#/definitions/controller.Response'
- properties:
data:
$ref: '#/definitions/plan.PlanResponse'
type: object
summary: 更新计划
tags:
- 计划管理
@@ -572,7 +630,7 @@ paths:
- application/json
responses:
"200":
description: 业务失败具体错误码和信息见响应体例如400, 404, 500
description: 业务码为200代表成功启动计划
schema:
$ref: '#/definitions/controller.Response'
summary: 启动计划
@@ -591,7 +649,7 @@ paths:
- application/json
responses:
"200":
description: 业务失败具体错误码和信息见响应体例如400, 404, 500
description: 业务码为200代表成功停止计划
schema:
$ref: '#/definitions/controller.Response'
summary: 停止计划
@@ -613,9 +671,14 @@ paths:
- application/json
responses:
"200":
description: 业务失败具体错误码和信息见响应体例如400, 409, 500
description: 业务码为201代表创建成功
schema:
$ref: '#/definitions/controller.Response'
allOf:
- $ref: '#/definitions/controller.Response'
- properties:
data:
$ref: '#/definitions/user.CreateUserResponse'
type: object
summary: 创建新用户
tags:
- 用户管理
@@ -635,9 +698,14 @@ paths:
- application/json
responses:
"200":
description: 业务失败具体错误码和信息见响应体例如400, 401, 500
description: 业务码为200代表登录成功
schema:
$ref: '#/definitions/controller.Response'
allOf:
- $ref: '#/definitions/controller.Response'
- properties:
data:
$ref: '#/definitions/user.LoginResponse'
type: object
summary: 用户登录
tags:
- 用户管理