Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

openapi3: no longer error when drilling into a silenced yaml tag #859

Merged
merged 1 commit into from
Nov 25, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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