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

Convert to v3 failed to handle openapi v2 bundle #279

Open
heyvister opened this issue Dec 28, 2020 · 2 comments
Open

Convert to v3 failed to handle openapi v2 bundle #279

heyvister opened this issue Dec 28, 2020 · 2 comments

Comments

@heyvister
Copy link
Contributor

Hi,

It look like openapi2_conv.go fails to support openapi v2 bundle conversion.
I didn't succeed converting the following v2 bundle example:
https://github.com/OAI/OpenAPI-Specification/tree/master/examples/v2.0/yaml/petstore-separate

Seems like there are several issues which needs to be fixed:

  • External references aren't supported: sl := openapi3.NewSwaggerLoader() @ ToV3Swagger() isn't exposing IsExternalRefsAllowed, so code is returns "encountered non-allowed external reference" error.
  • Converting definitions to components isn't supporting external references. Meaning, ToV3Ref is looking for v2 prefix instead of verifies whether v2 ref contains #/definitions (i.e v2 $ref: "./common.yaml#/definitions/someScheme" cannot be converted to v3 $ref: "./common.yaml#/components/schemas/someScheme"
  • External v2 references are expected to be v3, as sl.ResolveRefsIn(result, &URL) is used in ToV3Swagger. So I guess there should be a mechanism which tracks all v2 externa reference files (i.e parameters.yaml), and converts them to v3, prior to resolving v2 root openapi (i.e swagger.yaml) references.

I guess that there are more issues needs to be resolved here, is this already a known issue? (couldn't find it under all open issues)
Is there a plan to fix it?

Thanks

@fenollp
Copy link
Collaborator

fenollp commented Dec 28, 2020

Hi! Indeed as you're noting v3 supports external refs but not v2 and there's no plan for this AFAIK.
I'll definitely review any PR you send my way :)

@sacheth003
Copy link

Hey @fenollp, I just wanted to confirm whether your message was still the case. For example, I am seeing the following error when converting between a v2.T to a v3.T:

encountered disallowed external reference: "<internal file>"

Any recommended workarounds here if this is not supported? I'd imagine it would involve converting the base file to a v3 format, and then reading the new file with this library.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants