Skip to content

Commit

Permalink
omdriller
Browse files Browse the repository at this point in the history
Signed-off-by: Pierre Fenoll <[email protected]>
  • Loading branch information
fenollp committed Jan 4, 2023
1 parent d2b52e3 commit 607d4ba
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions openapi3/loader.go
Original file line number Diff line number Diff line change
Expand Up @@ -409,6 +409,10 @@ func drillIntoField(cursor interface{}, fieldName string) (interface{}, error) {
return enc, nil
}
}

if v := omdriller(val, fieldName); v != nil {
return v, nil
}
}
return nil, fmt.Errorf("struct field %q not found", fieldName)

Expand All @@ -417,6 +421,33 @@ func drillIntoField(cursor interface{}, fieldName string) (interface{}, error) {
}
}

func omdriller(val reflect.Value, fieldName string) interface{} {
// TODO: ge -B1 '^\s+om [*]orderedmap' -- openapi3/
switch tyname := val.Type().Name(); tyname {
case "Paths":
if om := val.Interface().(Paths).om; om != nil {
if v, ok := (*om).Get(fieldName); ok {
return v
}
}

case "Callbacks":
if om := val.Interface().(Callbacks).om; om != nil {
if v, ok := (*om).Get(fieldName); ok {
return v
}
}

case "Callback":
if om := val.Interface().(Callback).om; om != nil {
if v, ok := (*om).Get(fieldName); ok {
return v
}
}
}
return nil
}

func (loader *Loader) resolveRef(doc *T, ref string, path *url.URL) (*T, string, *url.URL, error) {
if ref != "" && ref[0] == '#' {
return doc, ref, path, nil
Expand Down

0 comments on commit 607d4ba

Please sign in to comment.