Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 704
TJ32 Avatar asked Apr 03 '20 19:04

TJ32


People also ask

Is OpenAPI the same as Swagger?

Although the terms once referred to the same thing, they can no longer be used interchangeably…even though some people still do. In 2021, OpenAPI refers to the industry-standard specification for RESTful API design. Swagger refers to a set of SmartBear tools.

Is OpenAPI widely used?

Huge Userbase. OpenAPI is used and backed by many big companies and can be seen as their condensed knowledge of building thousands of APIs over the years.

What is the difference between OpenAPI and REST API?

The OpenAPI Specification (OAS) defines a standard, programming language-agnostic interface description for REST APIs, which allows both humans and computers to discover and understand the capabilities of a service without requiring access to source code, additional documentation, or inspection of network traffic.

Is OpenAPI RESTful?

Originally known as the Swagger Specification, the OpenAPI Specification (OAS) is a format that can be used to describe, produce, consume, and visualize RESTful web services. It is a specification standard for REST APIs that defines the structure and syntax.


Video Answer


2 Answers

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 thy 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 proect where we would have liked to use openapi instead of swagger for this reson, unfortunately, the API GW did not support it yet...

like image 125
JoSSte Avatar answered Nov 15 '22 12:11

JoSSte


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.

like image 39
Jai Shirole Avatar answered Nov 15 '22 11:11

Jai Shirole