升级one level处理逻辑
This commit is contained in:
parent
33a5ec22b1
commit
723d0e477c
@ -135,7 +135,7 @@ func generatePathParameterConfig(swaggerInfo *define.Swagger, pathConfig *define
|
|||||||
parentPath := ""
|
parentPath := ""
|
||||||
if strings.ToUpper(itemParamInput.In) == consts.RequestLocationBody && !strings.Contains(realParamName, ".") {
|
if strings.ToUpper(itemParamInput.In) == consts.RequestLocationBody && !strings.Contains(realParamName, ".") {
|
||||||
realParamName = "jsonBody"
|
realParamName = "jsonBody"
|
||||||
parentPath = pathConfig.Uri + ".jsonBody"
|
parentPath = strings.ReplaceAll(pathConfig.Uri, ".", "-") + ".jsonBody"
|
||||||
}
|
}
|
||||||
generateParameterDefinitions(swaggerInfo, pathConfig.Uri, parentPath, itemParamInput.Name, itemParamInput)
|
generateParameterDefinitions(swaggerInfo, pathConfig.Uri, parentPath, itemParamInput.Name, itemParamInput)
|
||||||
if _, exist := hasDealTable[realParamName]; !exist {
|
if _, exist := hasDealTable[realParamName]; !exist {
|
||||||
@ -172,7 +172,7 @@ func generatePathResponseConfig(swaggerInfo *define.Swagger, pathConfig *define.
|
|||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
// name 可能是 x.x.x 递归数组, 或者 x.x.[].x
|
// name 可能是 x.x.x 递归数组, 或者 x.x.[].x
|
||||||
outputDefine := strings.TrimLeft(pathConfig.Uri, "/") + "." + itemResponseConfig.Code + ".output"
|
outputDefine := strings.TrimLeft(strings.ReplaceAll(pathConfig.Uri, ".", "-"), "/") + "." + itemResponseConfig.Code + ".output"
|
||||||
generateParameterDefinitions(swaggerInfo, pathConfig.Uri, outputDefine, itemResponseInput.Field, &define.SwaggerParameterInput{
|
generateParameterDefinitions(swaggerInfo, pathConfig.Uri, outputDefine, itemResponseInput.Field, &define.SwaggerParameterInput{
|
||||||
Type: itemResponseInput.Type,
|
Type: itemResponseInput.Type,
|
||||||
Description: itemResponseInput.Description,
|
Description: itemResponseInput.Description,
|
||||||
@ -202,7 +202,7 @@ func generatePathResponseConfig(swaggerInfo *define.Swagger, pathConfig *define.
|
|||||||
// Date : 14:06 2024/4/22
|
// Date : 14:06 2024/4/22
|
||||||
func generateParameterDefinitions(swaggerInfo *define.Swagger, uri string, parentPath string, subPath string, paramConfig *define.SwaggerParameterInput) {
|
func generateParameterDefinitions(swaggerInfo *define.Swagger, uri string, parentPath string, subPath string, paramConfig *define.SwaggerParameterInput) {
|
||||||
setGlobalMapDefinition(swaggerInfo, paramConfig.Type)
|
setGlobalMapDefinition(swaggerInfo, paramConfig.Type)
|
||||||
uri = strings.TrimLeft(uri, "/")
|
uri = strings.ReplaceAll(strings.TrimLeft(uri, "/"), ".", "-")
|
||||||
parentPath = strings.TrimLeft(parentPath, "/")
|
parentPath = strings.TrimLeft(parentPath, "/")
|
||||||
checkPath := getCheckPath(parentPath)
|
checkPath := getCheckPath(parentPath)
|
||||||
subPathArr := strings.Split(subPath, ".")
|
subPathArr := strings.Split(subPath, ".")
|
||||||
@ -302,6 +302,16 @@ func handleOneLevelSubPath(swaggerInfo *define.Swagger, uri string, parentPath s
|
|||||||
// 长度为1, 还不在 body, 无需生成结构体
|
// 长度为1, 还不在 body, 无需生成结构体
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
if strings.HasSuffix(paramConfig.Type, "[]") {
|
||||||
|
swaggerInfo.Definitions[parentPath].Properties[subPath] = &define.SwaggerDefinitionProperty{
|
||||||
|
Description: paramConfig.Description,
|
||||||
|
Type: consts.SwaggerDataTypeArray,
|
||||||
|
Items: map[string]string{
|
||||||
|
consts.SwaggerTypeKey: util.GetSwaggerType(strings.TrimSuffix(paramConfig.Type, "[]")),
|
||||||
|
},
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
if isGlobalMapType(paramConfig.Type) {
|
if isGlobalMapType(paramConfig.Type) {
|
||||||
swaggerInfo.Definitions[parentPath].Properties[subPath] = &define.SwaggerDefinitionProperty{
|
swaggerInfo.Definitions[parentPath].Properties[subPath] = &define.SwaggerDefinitionProperty{
|
||||||
Description: paramConfig.Description,
|
Description: paramConfig.Description,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user