Skip to content

Commit

Permalink
openapi3: no longer error when drilling into a silenced yaml tag (#859)
Browse files Browse the repository at this point in the history
Signed-off-by: Pierre Fenoll <pierrefenoll@gmail.com>
  • Loading branch information
fenollp committed Nov 25, 2023
1 parent 49395dd commit 40b56cb
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions openapi3/loader.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 40b56cb

Please sign in to comment.