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

Support transforming v3 spec to v2 in CLI #48

Open
wafflespeanut opened this issue Jul 16, 2019 · 8 comments
Open

Support transforming v3 spec to v2 in CLI #48

wafflespeanut opened this issue Jul 16, 2019 · 8 comments
Labels
enhancement New feature or request legendary A lot of work is involved! research Some investigation required prior to making changes.

Comments

@wafflespeanut
Copy link
Collaborator

It would be nice to support transforming a v3 spec to v2 using the paperclip CLI. I think v2 and v3 only change in their structure, but if there's something more, then we can use vendor extensions to cover whatever we need.

@wafflespeanut wafflespeanut added enhancement New feature or request legendary A lot of work is involved! labels Jul 16, 2019
@pickfire
Copy link

This would be a nice project to be done in https://github.com/pickfire/babelfish as well, maybe we could collaborate?

@wafflespeanut
Copy link
Collaborator Author

@pickfire I'd love to do that, but it looks like babelfish is a converter for encodings, whereas OpenAPI is a specification which could be in any encoding (JSON/YAML), so this is probably not in the scope of babelfish?

@pickfire
Copy link

pickfire commented Aug 3, 2019

Not really a converter for encodings, just a converter for stuff. Right now only encodings is there because encodings conversion is the easiest.

This is probably a good first non-encoding conversion.

@wafflespeanut
Copy link
Collaborator Author

... just a converter for stuff.

Isn't this ambiguous? Either way, it's probably time to update the scope of babelfish in its README and project description. 😄

Paperclip, on the other hand, is focusing entirely on tooling related to OpenAPI, which includes converting v3 to v2 and vice versa, which is why I believe it's well within the scope of this project.

@wafflespeanut
Copy link
Collaborator Author

One other thing I'd like to point out here is that the v2 and v3 spec aren't exactly interchangeable (v2 to v3 is straightforward, but the other way around isn't), so this also involves making a few decisions along the way, which may not be accepted by other OAPI tools because there's no universally accepted way to do that conversion.

@pickfire
Copy link

pickfire commented Aug 4, 2019

Isn't this ambiguous? Either way, it's probably time to update the scope of babelfish in its README and project description.

True, but I do like it being ambiguous rather than sprinkling around like how I see serde_*, even though some have very similar API (like serde_json and serde_cbor), it is not simple to just swap one with the other (like serde_yaml with serde_json).

So it might be good to have something for converting stuff, but at least try to get a similar API.

@wafflespeanut wafflespeanut added the research Some investigation required prior to making changes. label Aug 5, 2019
@jayvdb
Copy link

jayvdb commented Nov 2, 2022

This would be a nice workaround for #476

There are very few tools which can do this. c.f. https://stackoverflow.com/questions/56637299/convert-openapi-3-0-to-swagger-2-0

@jayvdb
Copy link

jayvdb commented Nov 3, 2022

The transformations I needed to get my openapi 3 doc accepted by the v2 parser:

  • Replace openapi: 3.x with swagger: 2.0
  • Move components.schemas mapping to be top level definitions , and transform any $ref value in the same way, i.e. changing "#/components/schemas/ABC" to "#/definitions/ABC"

The result isnt perfect, but it is good enough for what I need atm .

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request legendary A lot of work is involved! research Some investigation required prior to making changes.
Projects
None yet
Development

No branches or pull requests

3 participants