OpenAPI vs Swagger
OpenAPI and Swagger are today, distinct entities but actually have the same origin. In 2010, Tony Tam, then CEO of Reverb Technologies released the Swagger API specification. Tam developed the Swagger specification as a way to enable easy, interactive documentation for APIs. The Swagger specification quickly gained popularity, and in 2015, Reverb Technologies was acquired by SmartBear, a company that specializes in dev tools.
Swagger was renamed to OpenAPI in 2016 to reflect the fact that the specification was now open-source and free to use by anyone. The OpenAPI specification was donated to, and is now maintained by the OpenAPI Initiative, which is hosted by the Linux Foundation.
Smartbear kept the Swagger name and built tools to support API providers’ efforts to comply with the OpenAPI standard.
OpenAPI vs Swagger at a glance
OpenAPI is the specification: a vendor-neutral format for describing an HTTP API in YAML or JSON, maintained by the OpenAPI Initiative. Swagger is SmartBear’s set of tools (Swagger Editor, Swagger UI, and Swagger Codegen) that read and write OpenAPI documents. Swagger 2.0 was the last version of the spec under that name; OpenAPI 3.0 and 3.1 came after it.
| OpenAPI | Swagger | |
|---|---|---|
| What it is | A specification for describing HTTP APIs | A brand of tools built around that specification |
| Maintained by | The OpenAPI Initiative, under the Linux Foundation | SmartBear |
| Versions | 3.0 (2017) and 3.1 (2021) | Swagger 2.0 is the last spec version with the name; the tools track OpenAPI 3.x |
| What you write | An openapi.yaml or openapi.json description of your API | Nothing new; the tools consume and generate OpenAPI files |
| Use it for | Defining the contract an API and its consumers agree on | Editing, rendering, and generating code from that contract |
One of the key differences between OpenAPI and Swagger now is the way they are used. OpenAPI is simply a specification for creating and documenting APIs, while Swagger is a set of tools that can be used to implement and work with the OpenAPI specification. This means that you can use OpenAPI to create a description of your API, and then use Swagger tools to generate documentation, code, and other artifacts for that API.
Another difference between OpenAPI and Swagger is the level of support they offer for different API formats. OpenAPI is a specification that can be used with any format, including REST, JSON-RPC, and SOAP. In contrast, Swagger tools are specifically designed to work with REST APIs that use JSON or YAML for the request and response bodies.
Overall, OpenAPI and Swagger are both valuable tools for API development. OpenAPI provides a flexible specification for describing APIs, while Swagger offers a suite of tools for implementing and working with OpenAPI-based APIs. Write the OpenAPI document first, then pick whichever tools fit your workflow; Swagger’s are the best known, but many editors, linters, and SDK generators read the same file.