How To Convert Swagger 2.0 To OpenAPI 3.1

Today in this article, we will see a few easy-to-use techniques to Convert Swagger 2.0 To OpenAPI 3.1

We shall cover the below aspects of the article,

We will generate Open-definition JSON using 2.0 schema and 3.0 schema specifications.

Using Online Tooling for OpenAPI JSON Conversion

How To Convert Swagger 2.0 To OpenAPI 3.1 Using Swagger Editor

We can use Swagger Converter or Swagger Editor which are online tools to convert Swagger specification

https://editor.swagger.io/

Convert Swagger 20 To OpenAPI 31

The above conversion will give you,

openapi: 3.0.1
info:
  title: Swagger Petstore
  description: 'This is a sample server Petstore server.  You can find out more about     Swagger
    at [http://swagger.io](http://swagger.io) or on [irc.freenode.net, #swagger](http://swagger.io/irc/).      For
    this sample, you can use the api key `special-key` to test the authorization     filters.'
  termsOfService: http://swagger.io/terms/
  contact:
    email: [email protected]
  license:
    name: Apache 2.0
    url: http://www.apache.org/licenses/LICENSE-2.0.html
  version: 1.0.0
externalDocs:
  description: Find out more about Swagger
  url: http://swagger.io
servers:
- url: https://petstore.swagger.io/v2
- url: http://petstore.swagger.io/v2
tags:
- name: pet
  description: Everything about your Pets
  externalDocs:
    description: Find out more
    url: http://swagger.io
- name: store
  description: Access to Petstore o

Using API – Swagger Converter

If you have access to the below link,

https://converter.swagger.io/

The above POST route can be executed via Swagger for POSTMAN or SOAP UI.

Convert Swagger 20 To OpenAPI 31

How to Convert Swagger 3.1 to 2.0 in ASP.NET Core

If you already have API based on .NET core 3.1 or above supporting OpenApi then it’s very easy to create an OpenAPI v2 definition using the below code,

blank

Above using SerializeAsV2 set as true convert and generates the swagger.json for Swagger 2.0 definition.

Do you have any comments or ideas or any better suggestions to share?

Please sound off your comments below.

Happy Coding !!



Please bookmark this page and share it with your friends. Please Subscribe to the blog to receive notifications on freshly published(2024) best practices and guidelines for software design and development.



Leave a Reply

Your email address will not be published. Required fields are marked *