diff --git a/openapi3/schema.go b/openapi3/schema.go index acf88f191..986c8337e 100644 --- a/openapi3/schema.go +++ b/openapi3/schema.go @@ -841,14 +841,14 @@ func (schema *Schema) visitSetOperations(settings *schemaValidationSettings, val if schema.Discriminator != nil { /* Find mapped object by ref */ - if valuemap, okcheck := value.(map[string]interface{}); okcheck { + if valuemap, okcheck := value.(map[string]string); okcheck { pn := schema.Discriminator.PropertyName if discriminatorVal, okcheck := valuemap[pn]; okcheck { if len(schema.Discriminator.Mapping) > 0 { - if mapref, okcheck := schema.Discriminator.Mapping[discriminatorVal.(string)]; okcheck { - for _, item := range v { - if item.Ref == mapref { - return item.Value.visitJSON(settings, value) + if mapref, okcheck := schema.Discriminator.Mapping[discriminatorVal]; okcheck { + for _, oneof := range v { + if oneof.Ref == mapref { + return oneof.Value.visitJSON(settings, value) } } } @@ -857,9 +857,9 @@ func (schema *Schema) visitSetOperations(settings *schemaValidationSettings, val ``It is implied, that the property to which discriminator refers, contains the name of the target schema. In the example above, the objectType property should contain either simpleObject, or complexObject string.''*/ - for _, oneof := range schema.OneOf { - if strings.HasSuffix(oneof.Ref, discriminatorVal.(string)) { - return oneof.Value.visitJSON(settings, value) + for _, v := range schema.OneOf { + if strings.HasSuffix(v.Ref, discriminatorVal) { + return v.Value.visitJSON(settings, value) } } }