Skip to content

Commit

Permalink
openapi2conv: expose loader and location to ToV3
Browse files Browse the repository at this point in the history
  • Loading branch information
AriehSchneier committed Oct 25, 2023
1 parent c446426 commit 89cf12c
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions openapi2conv/openapi2_conv.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@ import (

// ToV3 converts an OpenAPIv2 spec to an OpenAPIv3 spec
func ToV3(doc2 *openapi2.T) (*openapi3.T, error) {
return ToV3WithLoader(doc2, openapi3.NewLoader(), nil)
}

func ToV3WithLoader(doc2 *openapi2.T, loader *openapi3.Loader, location *url.URL) (*openapi3.T, error) {
doc3 := &openapi3.T{
OpenAPI: "3.0.3",
Info: &doc2.Info,
Expand Down Expand Up @@ -107,8 +111,7 @@ func ToV3(doc2 *openapi2.T) (*openapi3.T, error) {

doc3.Security = ToV3SecurityRequirements(doc2.Security)
{
sl := openapi3.NewLoader()
if err := sl.ResolveRefsIn(doc3, nil); err != nil {
if err := loader.ResolveRefsIn(doc3, location); err != nil {
return nil, err
}
}
Expand Down

0 comments on commit 89cf12c

Please sign in to comment.