mirror of
https://github.com/zeromicro/go-zero.git
synced 2026-05-07 15:10:01 +08:00
fix array schmea generation incorrect (#4801)
This commit is contained in:
@@ -137,8 +137,7 @@ func parametersFromType(method string, tp apiSpec.Type) []spec.Parameter {
|
||||
if required {
|
||||
requiredFields = append(requiredFields, jsonTag.Name)
|
||||
}
|
||||
p, r := propertiesFromType(member.Type)
|
||||
properties[jsonTag.Name] = spec.Schema{
|
||||
var schema = spec.Schema{
|
||||
SwaggerSchemaProps: spec.SwaggerSchemaProps{
|
||||
Example: exampleValueFromOptions(jsonTag.Options, member.Type),
|
||||
},
|
||||
@@ -150,13 +149,19 @@ func parametersFromType(method string, tp apiSpec.Type) []spec.Parameter {
|
||||
ExclusiveMaximum: exclusiveMaximum,
|
||||
Minimum: minimum,
|
||||
ExclusiveMinimum: exclusiveMinimum,
|
||||
Enum: enumsValueFromOptions(jsonTag.Options),
|
||||
Items: itemsFromGoType(member.Type),
|
||||
Properties: p,
|
||||
Required: r,
|
||||
Enum: enumsValueFromOptions(jsonTag.Options),
|
||||
AdditionalProperties: mapFromGoType(member.Type),
|
||||
},
|
||||
}
|
||||
switch sampleTypeFromGoType(member.Type) {
|
||||
case swaggerTypeArray:
|
||||
schema.Items=itemsFromGoType(member.Type)
|
||||
case swaggerTypeObject:
|
||||
p, r := propertiesFromType(member.Type)
|
||||
schema.Properties = p
|
||||
schema.Required = r
|
||||
}
|
||||
properties[jsonTag.Name] = schema
|
||||
}
|
||||
})
|
||||
if len(properties) > 0 {
|
||||
|
||||
Reference in New Issue
Block a user