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.

5
  • 3
    Related: Convert OpenAPI 2.0 to OpenAPI 3.0
    – Helen
    Jan 15, 2020 at 10:42
  • 5
    @Helen misleading link, user asked foe convert 3 to 2, you linked 2 to 3
    – Reza
    Apr 29, 2021 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, 2021 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, 2021 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, 2021 at 20:34

3 Answers 3

88

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

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

1
  • Unsure this should not have been a comment, but this is good context
    – MrMesees
    Sep 20, 2022 at 22:58
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)!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.