fix data type
This commit is contained in:
parent
1d7b81cffa
commit
7d5e9a9d9c
28
common.go
28
common.go
@ -45,36 +45,36 @@ func GetUriPathParamList(uriPath string) []*define.ParamConfig {
|
|||||||
// Author : go_developer@163.com<白茶清欢>
|
// Author : go_developer@163.com<白茶清欢>
|
||||||
//
|
//
|
||||||
// Date : 11:52 2024/12/24
|
// 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)
|
docParamType = strings.ToLower(docParamType)
|
||||||
formatType = strings.ToLower(formatType)
|
formatType = strings.ToLower(formatType)
|
||||||
if len(formatType) == 0 {
|
if len(formatType) == 0 {
|
||||||
formatType = docParamType
|
formatType = docParamType
|
||||||
}
|
}
|
||||||
switch docParamType {
|
switch docParamType {
|
||||||
case "integer":
|
case consts.SwaggerDataTypeInteger:
|
||||||
if formatType == "int64" {
|
if formatType == "int64" {
|
||||||
return consts.DataTypeInt
|
return consts.DataTypeInt.String()
|
||||||
}
|
}
|
||||||
return consts.DataTypeUint
|
return consts.DataTypeUint.String()
|
||||||
case "string", "apikey":
|
case "string", "apikey":
|
||||||
return consts.DataTypeString
|
return consts.DataTypeString.String()
|
||||||
case "object":
|
case "object":
|
||||||
return consts.DataTypeMapStrAny
|
return consts.DataTypeMapStrAny.String()
|
||||||
case "boolean":
|
case "boolean":
|
||||||
return consts.DataTypeBool
|
return consts.DataTypeBool.String()
|
||||||
case "number", "float", "double", "float32", "float64":
|
case "number", "float", "double", "float32", "float64":
|
||||||
return consts.DataTypeFloat
|
return consts.DataTypeFloat.String()
|
||||||
case "array":
|
case "array":
|
||||||
if formatType == "integer" {
|
if formatType == "integer" {
|
||||||
return consts.DataTypeSliceInt
|
return consts.DataTypeSliceInt.String()
|
||||||
} else if formatType == "string" {
|
} else if formatType == "string" {
|
||||||
return consts.DataTypeSliceString
|
return consts.DataTypeSliceString.String()
|
||||||
} else {
|
} else {
|
||||||
return consts.DataTypeSliceAny
|
return consts.DataTypeSliceAny.String()
|
||||||
}
|
}
|
||||||
default:
|
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{
|
res = append(res, &define.ParamConfig{
|
||||||
Location: consts.RequestDataLocationBody.String(),
|
Location: consts.RequestDataLocationBody.String(),
|
||||||
Path: pathPrefix + "{{#idx#}}." + itemKey,
|
Path: pathPrefix + "{{#idx#}}." + itemKey,
|
||||||
Type: GetDataType(itemConfig.Type, "").String(),
|
Type: GetDataType(itemConfig.Type, ""),
|
||||||
Title: pathPrefix + itemKey,
|
Title: pathPrefix + itemKey,
|
||||||
Description: pathPrefix + itemKey,
|
Description: pathPrefix + itemKey,
|
||||||
Required: false,
|
Required: false,
|
||||||
@ -158,7 +158,7 @@ func ExpandArrayResult(swaggerDoc *define.Swagger, ref string, rootPath string)
|
|||||||
res = append(res, &define.ResultConfig{
|
res = append(res, &define.ResultConfig{
|
||||||
Location: consts.ResponseDataLocationBody.String(),
|
Location: consts.ResponseDataLocationBody.String(),
|
||||||
Path: pathPrefix + "{{#idx#}}." + itemKey,
|
Path: pathPrefix + "{{#idx#}}." + itemKey,
|
||||||
Type: GetDataType(itemConfig.Type, "").String(),
|
Type: GetDataType(itemConfig.Type, ""),
|
||||||
Title: pathPrefix + itemKey,
|
Title: pathPrefix + itemKey,
|
||||||
Description: pathPrefix + itemKey,
|
Description: pathPrefix + itemKey,
|
||||||
})
|
})
|
||||||
|
2
go.mod
2
go.mod
@ -3,7 +3,7 @@ module git.zhangdeman.cn/gateway/api-doc
|
|||||||
go 1.22.2
|
go 1.22.2
|
||||||
|
|
||||||
require (
|
require (
|
||||||
git.zhangdeman.cn/zhangdeman/consts v0.0.0-20250207132005-330777d80591
|
git.zhangdeman.cn/zhangdeman/consts v0.0.0-20250208020330-a50062af46a1
|
||||||
git.zhangdeman.cn/zhangdeman/serialize v0.0.0-20241223084948-de2e49144fcd
|
git.zhangdeman.cn/zhangdeman/serialize v0.0.0-20241223084948-de2e49144fcd
|
||||||
git.zhangdeman.cn/zhangdeman/wrapper v0.0.0-20250124091620-c757e551a8c9
|
git.zhangdeman.cn/zhangdeman/wrapper v0.0.0-20250124091620-c757e551a8c9
|
||||||
github.com/tidwall/gjson v1.18.0
|
github.com/tidwall/gjson v1.18.0
|
||||||
|
6
go.sum
6
go.sum
@ -1,9 +1,7 @@
|
|||||||
git.zhangdeman.cn/zhangdeman/consts v0.0.0-20250207125648-b75d2ec7f3c1 h1:qWqq6dWW2eIpaXvLBUjTrbOzX1xrSw/nswz2ZL7a8Zw=
|
|
||||||
git.zhangdeman.cn/zhangdeman/consts v0.0.0-20250207125648-b75d2ec7f3c1/go.mod h1:IXXaZkb7vGzGnGM5RRWrASAuwrVSNxuoe0DmeXx5g6k=
|
|
||||||
git.zhangdeman.cn/zhangdeman/consts v0.0.0-20250207130030-67b5d5cc6121 h1:48wtD5FTfQ6AiHWrFHg/IaCxzNWYRbuGlENWDhn0Fbw=
|
|
||||||
git.zhangdeman.cn/zhangdeman/consts v0.0.0-20250207130030-67b5d5cc6121/go.mod h1:IXXaZkb7vGzGnGM5RRWrASAuwrVSNxuoe0DmeXx5g6k=
|
|
||||||
git.zhangdeman.cn/zhangdeman/consts v0.0.0-20250207132005-330777d80591 h1:P58+JwVhycrAFqE2Eq25N9y5lDokYBUz+oLxCKk44BE=
|
git.zhangdeman.cn/zhangdeman/consts v0.0.0-20250207132005-330777d80591 h1:P58+JwVhycrAFqE2Eq25N9y5lDokYBUz+oLxCKk44BE=
|
||||||
git.zhangdeman.cn/zhangdeman/consts v0.0.0-20250207132005-330777d80591/go.mod h1:IXXaZkb7vGzGnGM5RRWrASAuwrVSNxuoe0DmeXx5g6k=
|
git.zhangdeman.cn/zhangdeman/consts v0.0.0-20250207132005-330777d80591/go.mod h1:IXXaZkb7vGzGnGM5RRWrASAuwrVSNxuoe0DmeXx5g6k=
|
||||||
|
git.zhangdeman.cn/zhangdeman/consts v0.0.0-20250208020330-a50062af46a1 h1:vv4X72I6s6XcTi0ykj2v/cgMZyseFyE2LkS4WloICCs=
|
||||||
|
git.zhangdeman.cn/zhangdeman/consts v0.0.0-20250208020330-a50062af46a1/go.mod h1:IXXaZkb7vGzGnGM5RRWrASAuwrVSNxuoe0DmeXx5g6k=
|
||||||
git.zhangdeman.cn/zhangdeman/op_type v0.0.0-20240122104027-4928421213c0 h1:gUDlQMuJ4xNfP2Abl1Msmpa3fASLWYkNlqDFF/6GN0Y=
|
git.zhangdeman.cn/zhangdeman/op_type v0.0.0-20240122104027-4928421213c0 h1:gUDlQMuJ4xNfP2Abl1Msmpa3fASLWYkNlqDFF/6GN0Y=
|
||||||
git.zhangdeman.cn/zhangdeman/op_type v0.0.0-20240122104027-4928421213c0/go.mod h1:VHb9qmhaPDAQDcS6vUiDCamYjZ4R5lD1XtVsh55KsMI=
|
git.zhangdeman.cn/zhangdeman/op_type v0.0.0-20240122104027-4928421213c0/go.mod h1:VHb9qmhaPDAQDcS6vUiDCamYjZ4R5lD1XtVsh55KsMI=
|
||||||
git.zhangdeman.cn/zhangdeman/serialize v0.0.0-20241223084948-de2e49144fcd h1:q7GG14qgXKB4MEXQFOe7/UYebsqMfPaSX80TcPdOosI=
|
git.zhangdeman.cn/zhangdeman/serialize v0.0.0-20241223084948-de2e49144fcd h1:q7GG14qgXKB4MEXQFOe7/UYebsqMfPaSX80TcPdOosI=
|
||||||
|
Loading…
x
Reference in New Issue
Block a user