From 40b56cb051caac370fbe8707dc89b09ad15f497d Mon Sep 17 00:00:00 2001 From: Pierre Fenoll Date: Sat, 25 Nov 2023 23:58:24 +0100 Subject: [PATCH] openapi3: no longer error when drilling into a silenced yaml tag (#859) Signed-off-by: Pierre Fenoll --- openapi3/loader.go | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/openapi3/loader.go b/openapi3/loader.go index e234e51b2..74ccab3f5 100644 --- a/openapi3/loader.go +++ b/openapi3/loader.go @@ -432,10 +432,15 @@ func drillIntoField(cursor interface{}, fieldName string) (interface{}, error) { hasFields := false for i := 0; i < val.NumField(); i++ { hasFields = true - if fieldName == strings.Split(val.Type().Field(i).Tag.Get("yaml"), ",")[0] { - return val.Field(i).Interface(), nil + if yamlTag := val.Type().Field(i).Tag.Get("yaml"); yamlTag != "-" { + if tagName := strings.Split(yamlTag, ",")[0]; tagName != "" { + if fieldName == tagName { + return val.Field(i).Interface(), nil + } + } } } + // if cursor is a "ref wrapper" struct (e.g. RequestBodyRef), if _, ok := val.Type().FieldByName("Value"); ok { // try digging into its Value field