fix data type

This commit is contained in:
2025-02-08 10:18:44 +08:00
parent 1d7b81cffa
commit 7d5e9a9d9c
3 changed files with 17 additions and 19 deletions

View File

@ -45,36 +45,36 @@ func GetUriPathParamList(uriPath string) []*define.ParamConfig {
// Author : go_developer@163.com<白茶清欢>
//
// Date : 11:52 2024/12/24
func GetDataType(docParamType string, formatType string) consts.DataType {
func GetDataType(docParamType string, formatType string) string {
docParamType = strings.ToLower(docParamType)
formatType = strings.ToLower(formatType)
if len(formatType) == 0 {
formatType = docParamType
}
switch docParamType {
case "integer":
case consts.SwaggerDataTypeInteger:
if formatType == "int64" {
return consts.DataTypeInt
return consts.DataTypeInt.String()
}
return consts.DataTypeUint
return consts.DataTypeUint.String()
case "string", "apikey":
return consts.DataTypeString
return consts.DataTypeString.String()
case "object":
return consts.DataTypeMapStrAny
return consts.DataTypeMapStrAny.String()
case "boolean":
return consts.DataTypeBool
return consts.DataTypeBool.String()
case "number", "float", "double", "float32", "float64":
return consts.DataTypeFloat
return consts.DataTypeFloat.String()
case "array":
if formatType == "integer" {
return consts.DataTypeSliceInt
return consts.DataTypeSliceInt.String()
} else if formatType == "string" {
return consts.DataTypeSliceString
return consts.DataTypeSliceString.String()
} else {
return consts.DataTypeSliceAny
return consts.DataTypeSliceAny.String()
}
default:
return consts.DataTypeAny
return consts.DataTypeAny.String()
}
}
@ -137,7 +137,7 @@ func ExpandArrayParam(swaggerDoc *define.Swagger, ref string, rootPath string) [
res = append(res, &define.ParamConfig{
Location: consts.RequestDataLocationBody.String(),
Path: pathPrefix + "{{#idx#}}." + itemKey,
Type: GetDataType(itemConfig.Type, "").String(),
Type: GetDataType(itemConfig.Type, ""),
Title: pathPrefix + itemKey,
Description: pathPrefix + itemKey,
Required: false,
@ -158,7 +158,7 @@ func ExpandArrayResult(swaggerDoc *define.Swagger, ref string, rootPath string)
res = append(res, &define.ResultConfig{
Location: consts.ResponseDataLocationBody.String(),
Path: pathPrefix + "{{#idx#}}." + itemKey,
Type: GetDataType(itemConfig.Type, "").String(),
Type: GetDataType(itemConfig.Type, ""),
Title: pathPrefix + itemKey,
Description: pathPrefix + itemKey,
})