优化swagger文档生成

This commit is contained in:
2025-02-07 21:27:33 +08:00
parent 28419222a7
commit 1d7b81cffa
6 changed files with 72 additions and 64 deletions

View File

@ -46,7 +46,7 @@ func TestGenerate(t *testing.T) {
TagList: []string{"测试接口生成"},
ParameterList: []*define.SwaggerParameterInput{
&define.SwaggerParameterInput{
Type: consts.DataTypeString,
Type: consts.DataTypeString.String(),
Description: "姓名",
Name: "name",
In: "body",
@ -54,7 +54,7 @@ func TestGenerate(t *testing.T) {
EnumList: []interface{}{"zhang", "de", "man"},
},
&define.SwaggerParameterInput{
Type: consts.DataTypeString,
Type: consts.DataTypeString.String(),
Description: "性别",
Name: "person.sex",
In: "body",
@ -62,7 +62,7 @@ func TestGenerate(t *testing.T) {
EnumList: []interface{}{"man", "woman", "other"},
},
&define.SwaggerParameterInput{
Type: consts.DataTypeString,
Type: consts.DataTypeString.String(),
Description: "性别",
Name: "person.job.list.[]",
In: "body",
@ -70,7 +70,7 @@ func TestGenerate(t *testing.T) {
EnumList: nil,
},
&define.SwaggerParameterInput{
Type: consts.DataTypeInt,
Type: consts.DataTypeInt.String(),
Description: "年份",
Name: "person.job.year.[]",
In: "body",
@ -78,7 +78,7 @@ func TestGenerate(t *testing.T) {
EnumList: nil,
},
&define.SwaggerParameterInput{
Type: consts.DataTypeInt,
Type: consts.DataTypeInt.String(),
Description: "测试工作",
Name: "person.job.test",
In: "body",
@ -86,7 +86,7 @@ func TestGenerate(t *testing.T) {
EnumList: nil,
},
&define.SwaggerParameterInput{
Type: consts.DataTypeInt,
Type: consts.DataTypeInt.String(),
Description: "年龄",
Name: "age",
In: "body",
@ -94,7 +94,7 @@ func TestGenerate(t *testing.T) {
EnumList: []interface{}{18, 19, 20},
},
&define.SwaggerParameterInput{
Type: consts.DataTypeInt,
Type: consts.DataTypeInt.String(),
Description: "年龄",
Name: "test_list.[].age",
In: "body",
@ -102,7 +102,7 @@ func TestGenerate(t *testing.T) {
EnumList: []interface{}{18, 19, 20},
},
&define.SwaggerParameterInput{
Type: consts.DataTypeString,
Type: consts.DataTypeString.String(),
Description: "年龄",
Name: "test_list.[].name",
In: "body",
@ -110,7 +110,7 @@ func TestGenerate(t *testing.T) {
EnumList: nil,
},
&define.SwaggerParameterInput{
Type: consts.DataTypeMapAnyAny,
Type: consts.DataTypeMapAnyAny.String(),
Description: "测试global_map",
Name: "obj",
In: "body",
@ -124,19 +124,19 @@ func TestGenerate(t *testing.T) {
Description: "成功",
List: []*define.SwaggerResponseItemInput{
&define.SwaggerResponseItemInput{
Type: consts.DataTypeString,
Type: consts.DataTypeString.String(),
Description: "姓名",
Field: "nick_name",
IsRequired: false,
},
&define.SwaggerResponseItemInput{
Type: consts.DataTypeString,
Type: consts.DataTypeString.String(),
Description: "昵称",
Field: "person.nick_name",
IsRequired: false,
},
&define.SwaggerResponseItemInput{
Type: consts.DataTypeMapAnyAny,
Type: consts.DataTypeMapAnyAny.String(),
Description: "测试返回生成map",
Field: "obj",
IsRequired: false,