优化变量
This commit is contained in:
@ -302,6 +302,18 @@ func handleOneLevelSubPath(swaggerInfo *define.Swagger, uri string, parentPath s
|
||||
// 长度为1, 还不在 body, 无需生成结构体
|
||||
return
|
||||
}
|
||||
if isGlobalMapType(paramConfig.Type) {
|
||||
swaggerInfo.Definitions[parentPath].Properties[subPath] = &define.SwaggerDefinitionProperty{
|
||||
Description: paramConfig.Description,
|
||||
Type: consts.SwaggerDataTypeObject,
|
||||
AllOf: []map[string]string{
|
||||
{
|
||||
consts.SwaggerRefKey: getRefValue(consts.SwaggerBaseObjectDefinitionName),
|
||||
},
|
||||
},
|
||||
}
|
||||
return
|
||||
}
|
||||
initAnyDefinition(swaggerInfo, parentPath)
|
||||
if paramConfig.Required {
|
||||
swaggerInfo.Definitions[parentPath].Required = append(swaggerInfo.Definitions[parentPath].Required, subPath)
|
||||
@ -325,14 +337,14 @@ func setGlobalMapDefinition(swaggerInfo *define.Swagger, dataType string) {
|
||||
if !isGlobalMapType(dataType) {
|
||||
return
|
||||
}
|
||||
// 只要最终类型存在mao, 就一定会用到 global_map
|
||||
// 只要最终类型存在mao, 就一定会用到 consts.SwaggerBaseObjectDefinitionName
|
||||
if nil == swaggerInfo.Definitions {
|
||||
swaggerInfo.Definitions = map[string]*define.SwaggerDefinition{}
|
||||
}
|
||||
if _, exist := swaggerInfo.Definitions["global_map"]; exist {
|
||||
if _, exist := swaggerInfo.Definitions[consts.SwaggerBaseObjectDefinitionName]; exist {
|
||||
return
|
||||
}
|
||||
swaggerInfo.Definitions["global_map"] = &define.SwaggerDefinition{
|
||||
swaggerInfo.Definitions[consts.SwaggerBaseObjectDefinitionName] = &define.SwaggerDefinition{
|
||||
Type: consts.SwaggerDataTypeObject,
|
||||
Required: make([]string, 0),
|
||||
Properties: make(map[string]*define.SwaggerDefinitionProperty),
|
||||
|
Reference in New Issue
Block a user