Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Convert OpenAPI 3.0 to Swagger 2.0

Is there a generator to convert OpenAPI 3.0 to Swagger 2.0?

Mashery, an API gateway, requires Swagger 2.0 format on input to open endpoint.

like image 238
Michal Foksa Avatar asked Jun 17 '19 18:06

Michal Foksa


People also ask

How do you change Swagger 2 to OpenAPI 3?

Swagger Editor has a Convert to OpenAPI 3 option under the Edit drop-down that acts as an interface to this API. All we need to do is open our document in Swagger Editor, then convert by using Edit > Convert to OpenAPI 3. This will replace our document with the OAS 3.0 version. It worked!

Is Swagger 3.0 backwards compatible?

It contains a variety of changes, and even though everything that can be expressed in Version 2 is supported in Version 3 as well, specifications are not backwards-compatible.

Is Swagger and OpenAPI the same?

OpenAPI 3.0 is the latest version of the specification. The Swagger tools, which are supported by SmartBear Software, are among the most popular tools for implementing the OpenAPI Specification, and will continue to maintain the Swagger name (Swagger Editor, Swagger UI, SwaggerHub, etc.)


2 Answers

  • LucyBot api-spec-converter (online version, GitHub repo, Node.js module) can convert from OpenAPI 3.0 to 2.0.

  • API Transformer also claims to be able to convert OpenAPI 3.0 back to OpenAPI 2.0. There's a command-line version too.

Keep in mind that OAS3→OAS2 convertion is lossy in general, because OAS3 has features that did not exist in OAS2 (such as multiple servers, oneOf/anyOf, different schemas per media type, objects in query string parameters, cookie parameters, and others).

like image 58
Helen Avatar answered Sep 19 '22 12:09

Helen


I needed version 2.0 for Power Automate.

When you are building some Azure Functions, try to create them in Visual Studio and enable any checkbox that is named Swagger not OpenAPI.

Now the API of your Azure Function contains the swagger.json that you can set into Power Automate Custom Connector.

like image 21
niek tuytel Avatar answered Sep 17 '22 12:09

niek tuytel