找到反射获取数组每一项数据类型的方法

This commit is contained in:
2025-02-08 21:27:40 +08:00
parent fce39068ca
commit 81975350c1
4 changed files with 24 additions and 11 deletions

View File

@ -54,7 +54,7 @@ func buildSwagger2GlobalSecurityParamList(swaggerDoc *define.Swagger) []*define.
result = append(result, &define.ParamConfig{
Location: GetParamLocation(paramConfig.In).String(),
Path: paramName,
Type: GetDataType(paramConfig.Type, "").String(),
Type: GetDataType(paramConfig.Type, ""),
Title: paramName,
Description: paramConfig.Description,
Required: false,
@ -72,8 +72,8 @@ func buildUriList(swaggerDoc *define.Swagger) ([]*define.UriBaseConfig, error) {
uriResult := &define.UriBaseConfig{
Uri: swaggerDoc.BasePath + "/" + strings.TrimLeft(itemUri, "/"),
Method: strings.ToUpper(requestMethod),
ContentType: methodConfig.Consumes[0],
OutputContentType: methodConfig.Produces[0],
ContentType: methodConfig.Consumes,
OutputContentType: methodConfig.Produces,
TagList: methodConfig.Tags,
Summary: methodConfig.Summary,
Description: methodConfig.Description,
@ -120,7 +120,7 @@ func buildSwagger2ParamConfig(swaggerDoc *define.Swagger, paramConfigList []*def
paramConfigBuildConfig := &define.ParamConfig{
Location: GetParamLocation(paramConfig.In).String(),
Path: paramConfig.Name,
Type: GetDataType(paramConfig.Type, paramConfig.Format).String(),
Type: GetDataType(paramConfig.Type, paramConfig.Format),
Title: paramConfig.Name,
Description: paramConfig.Description,
Required: paramConfig.Required,
@ -143,7 +143,7 @@ func buildSwagger2ParamConfig(swaggerDoc *define.Swagger, paramConfigList []*def
paramConfigBuildConfig := &define.ParamConfig{
Location: GetParamLocation(paramConfig.In).String(),
Path: paramName,
Type: GetDataType(paramMoreConfig.Type, "").String(),
Type: GetDataType(paramMoreConfig.Type, ""),
Title: paramName,
Description: paramMoreConfig.Description,
Required: requiredTable[paramName],
@ -204,7 +204,7 @@ func buildSwagger2ResultConfig(swaggerDoc *define.Swagger, resultConfig map[stri
responseType = consts.DataTypeAny.String()
} else {
schemaType = responseTypeDefine.Schema.Type
responseType = GetDataType(responseTypeDefine.Schema.Type, "").String()
responseType = GetDataType(responseTypeDefine.Schema.Type, "")
}
resCfg := &define.ResultConfig{
Location: consts.ResponseDataLocationBody.String(),
@ -223,7 +223,7 @@ func buildSwagger2ResultConfig(swaggerDoc *define.Swagger, resultConfig map[stri
res = append(res, &define.ResultConfig{
Location: consts.ResponseDataLocationBody.String(),
Path: responseKey,
Type: GetDataType(responseKeyConfig.Type, "").String(),
Type: GetDataType(responseKeyConfig.Type, ""),
Title: responseKey,
Description: responseKey,
})