74

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.

Grokify
  • 15,092
  • 6
  • 60
  • 81
Michal Foksa
  • 11,225
  • 9
  • 50
  • 68
  • 3
    Related: [Convert OpenAPI 2.0 to OpenAPI 3.0](https://stackoverflow.com/q/59749513/113116) – Helen Jan 15 '20 at 10:42
  • 5
    @Helen misleading link, user asked foe convert 3 to 2, you linked 2 to 3 – Reza Apr 29 '21 at 19:36
  • 3
    @Reza As you've (correctly) noted, the related link is for the _opposite conversion_, it's posted just in case some readers may need it too. I don't see what's misleading about this. – Helen May 28 '21 at 12:49
  • 1
    @Helen the question is "Convert 3 to 2" and you posted "Convert 2 to 3", usually when related is tagged under a question means it's already answered there – Reza May 28 '21 at 13:17
  • 5
    @Reza that would be "duplicate" & closed as such, not "related". You and I seem to have different definitions of "related". – Helen May 28 '21 at 20:34

3 Answers3

87

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).

Helen
  • 87,344
  • 17
  • 243
  • 314
  • Note that https://www.apimatic.io/transformer and the CLI "version" of https://www.apimatic.io/transformer depend on a paid account. – John Vandenberg Nov 01 '22 at 08:16
3

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.

Helen
  • 87,344
  • 17
  • 243
  • 314
niek tuytel
  • 899
  • 7
  • 18
0

There is also an abandoned GitHub project https://github.com/kongchen/swagger-maven-plugin that is quite useful. We forked this project and adapted it to our needs (we have to use Google Endpoints which requires OAS 2.0)!

electrobabe
  • 1,549
  • 18
  • 17