Thejus32
Thejus32

Reputation: 371

OpenAPI vs swagger

What is the actual advantage of using OpenApi over swagger?

I am new to openApi technology, just wanted to know what more features are present in openApi than in swagger. The online documents didn't helped me. Can anyone help me.

Upvotes: 12

Views: 8870

Answers (2)

JoSSte
JoSSte

Reputation: 3372

OpenApi is essentially a further development of swagger, hence the version 3.0.0 instead of 1.0.0

If you read the swagger blog Swagger was handed over to the OpenAPI Initiative, and all the swagger tools like editor.swagger.io support OpenAPI, and conversions between the two.

as they write

OpenAPI = Specification
Swagger = Tools for implementing the specification

(and swagger is also the term for the first two iterations of the spec)

If you are not restricted by a specific version, I would recommend openapi, since the community is in theory bigger, and there has happened a lot since swagger v. 2.0.0, such as simplification and ease of use.

more security schemes are supported, enhanced parameter types based on whether they are in the path, query, header or a cookie.

Also there is an improvement in how you can define examples. I have participated in a project where we would have liked to use openapi instead of swagger for this reason, unfortunately, the API GW did not support it yet...

Upvotes: 12

Jai Shirole
Jai Shirole

Reputation: 21

Swagger 2.0 was quite popular until OpenAPI 3.0 came out with lots of improvements, consolidation of fields. There are many tools available supporting the new spec for parsing/validating, etc. In addition to what has already been called out in above response, I find the changes in specifying the 'server' as quite important.

Swagger 2.0 allowed just one host+basepath combination and the only flexibility was http & https schemes. It wasn't useful where you might have multiple subdomains for API Host or in case of SaaS world, you may have variables for tenants.

"host": "petstore.swagger.io",
"basePath": "/v1",
"schemes": [
  "http",
  "https"
]

OpenAPI3.0 addressed this requirement by adding multiple server URLs, along with variable definitions for placeholders in the URL. It went a step ahead to define servers at the paths and even at the operations level.

Another is variety in parameter specification. Swagger 2.0 had limited support for parameters with respect to type (mostly primitives except for body schema was allowed) and cookie wasn't supported. OpenAPI 3.0 allows schema even for parameters and separates body into a dedicated requestBody field. The cookie is additional in place to send the parameters now.

In a nutshell, OpenAPI 3.0 is now made very exhaustive to support several use cases and might make sense to consider it.

Upvotes: 2

Related Questions