Open heyvister opened 3 years ago
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 :)
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.
Hi,
It look like _openapi2conv.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:
sl := openapi3.NewSwaggerLoader()
@ToV3Swagger()
isn't exposingIsExternalRefsAllowed
, so code is returns"encountered non-allowed external reference"
error.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"
sl.ResolveRefsIn(result, &URL)
is used inToV3Swagger
. 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