mirror of
https://github.com/LukeHagar/libopenapi.git
synced 2025-12-10 04:20:24 +00:00
added check for polymorphic types coming through as non objects
renderer was panicing with strangely shaped schemas.
This commit is contained in:
@@ -320,10 +320,15 @@ func (wr *SchemaRenderer) DiveIntoSchema(schema *base.Schema, key string, struct
|
|||||||
for _, allOfSchema := range allOf {
|
for _, allOfSchema := range allOf {
|
||||||
allOfCompiled := allOfSchema.Schema()
|
allOfCompiled := allOfSchema.Schema()
|
||||||
wr.DiveIntoSchema(allOfCompiled, allOfType, allOfMap, depth+1)
|
wr.DiveIntoSchema(allOfCompiled, allOfType, allOfMap, depth+1)
|
||||||
for k, v := range allOfMap[allOfType].(map[string]any) {
|
if m, ok := allOfMap[allOfType].(map[string]any); ok {
|
||||||
|
for k, v := range m {
|
||||||
propertyMap[k] = v
|
propertyMap[k] = v
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if m, ok := allOfMap[allOfType].(string); ok {
|
||||||
|
propertyMap[allOfType] = m
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// handle dependentSchemas
|
// handle dependentSchemas
|
||||||
@@ -349,10 +354,15 @@ func (wr *SchemaRenderer) DiveIntoSchema(schema *base.Schema, key string, struct
|
|||||||
oneOfMap := make(map[string]any)
|
oneOfMap := make(map[string]any)
|
||||||
oneOfCompiled := oneOf[0].Schema()
|
oneOfCompiled := oneOf[0].Schema()
|
||||||
wr.DiveIntoSchema(oneOfCompiled, oneOfType, oneOfMap, depth+1)
|
wr.DiveIntoSchema(oneOfCompiled, oneOfType, oneOfMap, depth+1)
|
||||||
for k, v := range oneOfMap[oneOfType].(map[string]any) {
|
if m, ok := oneOfMap[oneOfType].(map[string]any); ok {
|
||||||
|
for k, v := range m {
|
||||||
propertyMap[k] = v
|
propertyMap[k] = v
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if m, ok := oneOfMap[oneOfType].(string); ok {
|
||||||
|
propertyMap[oneOfType] = m
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// handle anyOf
|
// handle anyOf
|
||||||
anyOf := schema.AnyOf
|
anyOf := schema.AnyOf
|
||||||
@@ -360,10 +370,15 @@ func (wr *SchemaRenderer) DiveIntoSchema(schema *base.Schema, key string, struct
|
|||||||
anyOfMap := make(map[string]any)
|
anyOfMap := make(map[string]any)
|
||||||
anyOfCompiled := anyOf[0].Schema()
|
anyOfCompiled := anyOf[0].Schema()
|
||||||
wr.DiveIntoSchema(anyOfCompiled, anyOfType, anyOfMap, depth+1)
|
wr.DiveIntoSchema(anyOfCompiled, anyOfType, anyOfMap, depth+1)
|
||||||
for k, v := range anyOfMap[anyOfType].(map[string]any) {
|
if m, ok := anyOfMap[anyOfType].(map[string]any); ok {
|
||||||
|
for k, v := range m {
|
||||||
propertyMap[k] = v
|
propertyMap[k] = v
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if m, ok := anyOfMap[anyOfType].(string); ok {
|
||||||
|
propertyMap[anyOfType] = m
|
||||||
|
}
|
||||||
|
}
|
||||||
structure[key] = propertyMap
|
structure[key] = propertyMap
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user