From 1e31a0a79e7c684812daba03db1bee44cc76cc1b Mon Sep 17 00:00:00 2001 From: Riccardo Manfrin Date: Fri, 23 Apr 2021 15:11:20 +0200 Subject: [PATCH] Compliance --- openapi3/schema.go | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) 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) } } }