Convert array/map of native types properly

This commit is contained in:
Darren Shepherd 2020-09-10 21:34:27 -07:00
parent 9b7fcc9a01
commit d496dd31d1

View File

@ -61,14 +61,18 @@ func toResourceField(name string, schema v1beta1.JSONSchemaProps, schemasMap map
case "array":
if itemSchema == nil {
f.Type = "array[json]"
} else {
} else if itemSchema.Type == "object" {
f.Type = "array[" + name + "]"
modelV3ToSchema(name, itemSchema, schemasMap)
} else {
f.Type = "array[" + itemSchema.Type + "]"
}
case "object":
if schema.AdditionalProperties != nil && schema.AdditionalProperties.Schema != nil {
if schema.AdditionalProperties != nil && schema.AdditionalProperties.Schema != nil && schema.AdditionalProperties.Schema.Type == "object" {
f.Type = "map[" + name + "]"
modelV3ToSchema(name, schema.AdditionalProperties.Schema, schemasMap)
} else if schema.AdditionalProperties != nil && schema.AdditionalProperties.Schema != nil {
f.Type = "map[" + schema.AdditionalProperties.Schema.Type + "]"
} else {
f.Type = name
modelV3ToSchema(name, &schema, schemasMap)