swagger2版本文档解析1.0版本 #2

Merged
zhangdeman merged 14 commits from feature/upgrade_parse_swag into master 2024-12-25 15:00:17 +08:00
2 changed files with 25 additions and 8 deletions
Showing only changes of commit 4bae125445 - Show all commits

View File

@ -58,6 +58,16 @@ func GetParamType(docParamType string, formatType string) consts.DataType {
return consts.DataTypeUint return consts.DataTypeUint
case "string": case "string":
return consts.DataTypeString return consts.DataTypeString
case "object":
return consts.DataTypeMapStrAny
case "array":
if formatType == "integer" {
return consts.DataTypeSliceInt
} else if formatType == "string" {
return consts.DataTypeSliceString
} else {
return consts.DataTypeSliceAny
}
default: default:
return consts.DataTypeMapStrAny return consts.DataTypeMapStrAny
} }

View File

@ -36,10 +36,10 @@ type SwaggerPathConfigParameter struct {
In string `json:"in"` // 参数位置 In string `json:"in"` // 参数位置
Required bool `json:"required"` // 是否必传 Required bool `json:"required"` // 是否必传
EnumList []any `json:"enum_list,omitempty"` // 枚举值列表 EnumList []any `json:"enum_list,omitempty"` // 枚举值列表
Schema *SwaggerPathConfigParameterScheme `json:"schema"` // 参数schema Schema *SwaggerPathConfigParameterSchema `json:"schema"` // 参数schema
} }
type SwaggerPathConfigParameterScheme struct { type SwaggerPathConfigParameterSchema struct {
Ref string `json:"$ref"` // 引用的数据结构定义 Ref string `json:"$ref"` // 引用的数据结构定义
} }
@ -81,12 +81,19 @@ type SwaggerDefinition struct {
type SwaggerDefinitionProperty struct { type SwaggerDefinitionProperty struct {
Description string `json:"description"` // 描述 Description string `json:"description"` // 描述
Type string `json:"type"` // 类型 Type string `json:"type"` // 类型
Items map[string]string `json:"items,omitempty"` // 引用类型中的引用(数组) Items *SwaggerDefinitionPropertyItem `json:"items,omitempty"` // 引用类型中的引用(数组)
AllOf []map[string]string `json:"allOf,omitempty"` // 引用类型中的引用(对象) AllOf []map[string]string `json:"allOf,omitempty"` // 引用类型中的引用(对象)
XGoName string `json:"x-go-name"` // go字段名称 XGoName string `json:"x-go-name"` // go字段名称
XGoPackage string `json:"x-go-package"` // go 包路径 XGoPackage string `json:"x-go-package"` // go 包路径
} }
// SwaggerDefinitionPropertyItem 属性item兴义
type SwaggerDefinitionPropertyItem struct {
Type string `json:"type"` // 类型
Ref string `json:"$ref"` // 引用
Enum []any `json:"enum"` // 枚举值
}
// Swagger 文档整体结构定义 // Swagger 文档整体结构定义
// //
// Author : go_developer@163.com<白茶清欢> // Author : go_developer@163.com<白茶清欢>