diff --git a/common.go b/common.go index ddd2043..a7c03b2 100644 --- a/common.go +++ b/common.go @@ -58,6 +58,16 @@ func GetParamType(docParamType string, formatType string) consts.DataType { return consts.DataTypeUint case "string": 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: return consts.DataTypeMapStrAny } diff --git a/define/swagger.go b/define/swagger.go index b7bdcea..8c1d4b2 100644 --- a/define/swagger.go +++ b/define/swagger.go @@ -36,10 +36,10 @@ type SwaggerPathConfigParameter struct { In string `json:"in"` // 参数位置 Required bool `json:"required"` // 是否必传 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"` // 引用的数据结构定义 } @@ -79,12 +79,19 @@ type SwaggerDefinition struct { // // Date : 17:25 2024/4/19 type SwaggerDefinitionProperty struct { - Description string `json:"description"` // 描述 - Type string `json:"type"` // 类型 - Items map[string]string `json:"items,omitempty"` // 引用类型中的引用(数组) - AllOf []map[string]string `json:"allOf,omitempty"` // 引用类型中的引用(对象) - XGoName string `json:"x-go-name"` // go字段名称 - XGoPackage string `json:"x-go-package"` // go 包路径 + Description string `json:"description"` // 描述 + Type string `json:"type"` // 类型 + Items *SwaggerDefinitionPropertyItem `json:"items,omitempty"` // 引用类型中的引用(数组) + AllOf []map[string]string `json:"allOf,omitempty"` // 引用类型中的引用(对象) + XGoName string `json:"x-go-name"` // 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 文档整体结构定义