Skip to content

Commit 7ab37e0

Browse files
committed
Update swagger
1 parent f04fdd5 commit 7ab37e0

File tree

8 files changed

+398
-118
lines changed

8 files changed

+398
-118
lines changed

internal/app/api/mock/mock_demo.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ type Demo struct {
1919
// @Param current query int true "分页索引" default(1)
2020
// @Param pageSize query int true "分页大小" default(10)
2121
// @Param queryValue query string false "查询值"
22-
// @Success 200 {array} schema.Demo "查询结果:{list:列表数据,pagination:{current:页索引,pageSize:页大小,total:总数量}}"
22+
// @Success 200 {object} schema.ListResult{list=[]schema.Demo} "查询结果"
2323
// @Failure 401 {object} schema.ErrorResult "{error:{code:0,message:未授权}}"
2424
// @Failure 500 {object} schema.ErrorResult "{error:{code:0,message:服务器错误}}"
2525
// @Router /api/v1/demos [get]

internal/app/api/mock/mock_login.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ func (a *Login) GetUserInfo(c *gin.Context) {
7878
// @Tags 登录管理
7979
// @Summary 查询当前用户菜单树
8080
// @Security ApiKeyAuth
81-
// @Success 200 {object} schema.Menu "查询结果:{list:菜单树}"
81+
// @Success 200 {object} schema.ListResult{list=[]schema.MenuTree} "查询结果"
8282
// @Failure 401 {object} schema.ErrorResult "{error:{code:0,message:未授权}}"
8383
// @Failure 500 {object} schema.ErrorResult "{error:{code:0,message:服务器错误}}"
8484
// @Router /api/v1/pub/current/menutree [get]

internal/app/api/mock/mock_menu.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ type Menu struct{}
2121
// @Param status query int false "状态(1:启用 2:禁用)"
2222
// @Param showStatus query int false "显示状态(1:显示 2:隐藏)"
2323
// @Param parentID query string false "父级ID"
24-
// @Success 200 {array} schema.Menu "查询结果:{list:列表数据,pagination:{current:页索引,pageSize:页大小,total:总数量}}"
24+
// @Success 200 {object} schema.ListResult{list=[]schema.Menu} "查询结果"
2525
// @Failure 401 {object} schema.ErrorResult "{error:{code:0,message:未授权}}"
2626
// @Failure 500 {object} schema.ErrorResult "{error:{code:0,message:服务器错误}}"
2727
// @Router /api/v1/menus [get]
@@ -34,7 +34,7 @@ func (a *Menu) Query(c *gin.Context) {
3434
// @Security ApiKeyAuth
3535
// @Param status query int false "状态(1:启用 2:禁用)"
3636
// @Param parentID query string false "父级ID"
37-
// @Success 200 {array} schema.MenuTree "查询结果:{list:列表数据}"
37+
// @Success 200 {object} schema.ListResult{list=[]schema.MenuTree} "查询结果"
3838
// @Failure 401 {object} schema.ErrorResult "{error:{code:0,message:未授权}}"
3939
// @Failure 500 {object} schema.ErrorResult "{error:{code:0,message:服务器错误}}"
4040
// @Router /api/v1/menus.tree [get]

internal/app/api/mock/mock_role.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ type Role struct {
2020
// @Param pageSize query int true "分页大小" default(10)
2121
// @Param queryValue query string false "查询值"
2222
// @Param status query int false "状态(1:启用 2:禁用)"
23-
// @Success 200 {array} schema.Role "查询结果:{list:列表数据,pagination:{current:页索引,pageSize:页大小,total:总数量}}"
23+
// @Success 200 {object} schema.ListResult{list=[]schema.Role} "查询结果"
2424
// @Failure 401 {object} schema.ErrorResult "{error:{code:0,message:未授权}}"
2525
// @Failure 500 {object} schema.ErrorResult "{error:{code:0,message:服务器错误}}"
2626
// @Router /api/v1/roles [get]
@@ -33,7 +33,7 @@ func (a *Role) Query(c *gin.Context) {
3333
// @Security ApiKeyAuth
3434
// @Param queryValue query string false "查询值"
3535
// @Param status query int false "状态(1:启用 2:禁用)"
36-
// @Success 200 {array} schema.Role "查询结果:{list:角色列表}"
36+
// @Success 200 {object} schema.ListResult{list=[]schema.Role} "查询结果"
3737
// @Failure 400 {object} schema.ErrorResult "{error:{code:0,message:未知的查询类型}}"
3838
// @Failure 401 {object} schema.ErrorResult "{error:{code:0,message:未授权}}"
3939
// @Failure 500 {object} schema.ErrorResult "{error:{code:0,message:服务器错误}}"

internal/app/api/mock/mock_user.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ type User struct {
2121
// @Param queryValue query string false "查询值"
2222
// @Param roleIDs query string false "角色ID(多个以英文逗号分隔)"
2323
// @Param status query int false "状态(1:启用 2:停用)"
24-
// @Success 200 {array} schema.UserShow "查询结果:{list:列表数据,pagination:{current:页索引,pageSize:页大小,total:总数量}}"
24+
// @Success 200 {object} schema.ListResult{list=[]schema.UserShow} "查询结果"
2525
// @Failure 401 {object} schema.ErrorResult "{error:{code:0,message:未授权}}"
2626
// @Failure 500 {object} schema.ErrorResult "{error:{code:0,message:服务器错误}}"
2727
// @Router /api/v1/users [get]

internal/app/swagger/docs.go

Lines changed: 152 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -65,12 +65,24 @@ var doc = `{
6565
],
6666
"responses": {
6767
"200": {
68-
"description": "查询结果:{list:列表数据,pagination:{current:页索引,pageSize:页大小,total:总数量}}",
69-
"schema": {
70-
"type": "array",
71-
"items": {
72-
"$ref": "#/definitions/schema.Demo"
73-
}
68+
"description": "查询结果",
69+
"schema": {
70+
"allOf": [
71+
{
72+
"$ref": "#/definitions/schema.ListResult"
73+
},
74+
{
75+
"type": "object",
76+
"properties": {
77+
"list": {
78+
"type": "array",
79+
"items": {
80+
"$ref": "#/definitions/schema.Demo"
81+
}
82+
}
83+
}
84+
}
85+
]
7486
}
7587
},
7688
"401": {
@@ -418,12 +430,24 @@ var doc = `{
418430
],
419431
"responses": {
420432
"200": {
421-
"description": "查询结果:{list:列表数据,pagination:{current:页索引,pageSize:页大小,total:总数量}}",
422-
"schema": {
423-
"type": "array",
424-
"items": {
425-
"$ref": "#/definitions/schema.Menu"
426-
}
433+
"description": "查询结果",
434+
"schema": {
435+
"allOf": [
436+
{
437+
"$ref": "#/definitions/schema.ListResult"
438+
},
439+
{
440+
"type": "object",
441+
"properties": {
442+
"list": {
443+
"type": "array",
444+
"items": {
445+
"$ref": "#/definitions/schema.Menu"
446+
}
447+
}
448+
}
449+
}
450+
]
427451
}
428452
},
429453
"401": {
@@ -516,12 +540,24 @@ var doc = `{
516540
],
517541
"responses": {
518542
"200": {
519-
"description": "查询结果:{list:列表数据}",
520-
"schema": {
521-
"type": "array",
522-
"items": {
523-
"$ref": "#/definitions/schema.MenuTree"
524-
}
543+
"description": "查询结果",
544+
"schema": {
545+
"allOf": [
546+
{
547+
"$ref": "#/definitions/schema.ListResult"
548+
},
549+
{
550+
"type": "object",
551+
"properties": {
552+
"list": {
553+
"type": "array",
554+
"items": {
555+
"$ref": "#/definitions/schema.MenuTree"
556+
}
557+
}
558+
}
559+
}
560+
]
525561
}
526562
},
527563
"401": {
@@ -779,9 +815,24 @@ var doc = `{
779815
"summary": "查询当前用户菜单树",
780816
"responses": {
781817
"200": {
782-
"description": "查询结果:{list:菜单树}",
783-
"schema": {
784-
"$ref": "#/definitions/schema.Menu"
818+
"description": "查询结果",
819+
"schema": {
820+
"allOf": [
821+
{
822+
"$ref": "#/definitions/schema.ListResult"
823+
},
824+
{
825+
"type": "object",
826+
"properties": {
827+
"list": {
828+
"type": "array",
829+
"items": {
830+
"$ref": "#/definitions/schema.MenuTree"
831+
}
832+
}
833+
}
834+
}
835+
]
785836
}
786837
},
787838
"401": {
@@ -1072,12 +1123,24 @@ var doc = `{
10721123
],
10731124
"responses": {
10741125
"200": {
1075-
"description": "查询结果:{list:列表数据,pagination:{current:页索引,pageSize:页大小,total:总数量}}",
1076-
"schema": {
1077-
"type": "array",
1078-
"items": {
1079-
"$ref": "#/definitions/schema.Role"
1080-
}
1126+
"description": "查询结果",
1127+
"schema": {
1128+
"allOf": [
1129+
{
1130+
"$ref": "#/definitions/schema.ListResult"
1131+
},
1132+
{
1133+
"type": "object",
1134+
"properties": {
1135+
"list": {
1136+
"type": "array",
1137+
"items": {
1138+
"$ref": "#/definitions/schema.Role"
1139+
}
1140+
}
1141+
}
1142+
}
1143+
]
10811144
}
10821145
},
10831146
"401": {
@@ -1170,12 +1233,24 @@ var doc = `{
11701233
],
11711234
"responses": {
11721235
"200": {
1173-
"description": "查询结果:{list:角色列表}",
1174-
"schema": {
1175-
"type": "array",
1176-
"items": {
1177-
"$ref": "#/definitions/schema.Role"
1178-
}
1236+
"description": "查询结果",
1237+
"schema": {
1238+
"allOf": [
1239+
{
1240+
"$ref": "#/definitions/schema.ListResult"
1241+
},
1242+
{
1243+
"type": "object",
1244+
"properties": {
1245+
"list": {
1246+
"type": "array",
1247+
"items": {
1248+
"$ref": "#/definitions/schema.Role"
1249+
}
1250+
}
1251+
}
1252+
}
1253+
]
11791254
}
11801255
},
11811256
"400": {
@@ -1475,12 +1550,24 @@ var doc = `{
14751550
],
14761551
"responses": {
14771552
"200": {
1478-
"description": "查询结果:{list:列表数据,pagination:{current:页索引,pageSize:页大小,total:总数量}}",
1479-
"schema": {
1480-
"type": "array",
1481-
"items": {
1482-
"$ref": "#/definitions/schema.UserShow"
1483-
}
1553+
"description": "查询结果",
1554+
"schema": {
1555+
"allOf": [
1556+
{
1557+
"$ref": "#/definitions/schema.ListResult"
1558+
},
1559+
{
1560+
"type": "object",
1561+
"properties": {
1562+
"list": {
1563+
"type": "array",
1564+
"items": {
1565+
"$ref": "#/definitions/schema.UserShow"
1566+
}
1567+
}
1568+
}
1569+
}
1570+
]
14841571
}
14851572
},
14861573
"401": {
@@ -1848,6 +1935,18 @@ var doc = `{
18481935
}
18491936
}
18501937
},
1938+
"schema.ListResult": {
1939+
"type": "object",
1940+
"properties": {
1941+
"list": {
1942+
"type": "object"
1943+
},
1944+
"pagination": {
1945+
"type": "object",
1946+
"$ref": "#/definitions/schema.PaginationResult"
1947+
}
1948+
}
1949+
},
18511950
"schema.LoginCaptcha": {
18521951
"type": "object",
18531952
"properties": {
@@ -2093,6 +2192,20 @@ var doc = `{
20932192
"$ref": "#/definitions/schema.MenuTree"
20942193
}
20952194
},
2195+
"schema.PaginationResult": {
2196+
"type": "object",
2197+
"properties": {
2198+
"current": {
2199+
"type": "integer"
2200+
},
2201+
"pageSize": {
2202+
"type": "integer"
2203+
},
2204+
"total": {
2205+
"type": "integer"
2206+
}
2207+
}
2208+
},
20962209
"schema.Role": {
20972210
"type": "object",
20982211
"required": [

0 commit comments

Comments
 (0)