修复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",