Dev tools

OpenAPI vs Swagger: What's the Difference?

OpenAPI vs Swagger: OpenAPI is the API description standard, Swagger is SmartBear's tools for it. History, versions, 2.0 to 3.x changes and tool choices.

By OmniAI Editorial · Nov 23, 2026 · 12 min read

In OpenAPI vs Swagger, the short answer is that OpenAPI is the specification and Swagger is a family of tools. The OpenAPI Specification (OAS) is an open standard, governed by the OpenAPI Initiative under the Linux Foundation, for describing HTTP APIs in a YAML or JSON file: endpoints, parameters, request and response bodies, authentication. Swagger is the original name of that specification, and today the brand of SmartBear's tools that work with it, such as Swagger UI, Swagger Editor and Swagger Codegen.

The difference between Swagger and OpenAPI confuses people because of history: until 2016, the specification itself was called Swagger. "Swagger 2.0" files still exist everywhere, and many people use "Swagger" to mean any API description file. This guide explains the history, what changed between Swagger 2.0 and OpenAPI 3.x with side-by-side examples, the tools on both sides, and what to use for a new API.

OpenAPI vs Swagger at a Glance

OpenAPISwagger
What it isA specification (a standard file format)A set of tools, and the old name of the specification
OwnerOpenAPI Initiative, a Linux Foundation projectSmartBear (tools); the specification was donated in 2015
Current versions3.0.x, 3.1.x and 3.2.xTools support Swagger 2.0 and OpenAPI 3.x files to varying degrees
File keyopenapi: 3.1.0swagger: "2.0" in old files
LicenceOpen specificationCore tools are open source; SmartBear also sells commercial products
ExamplesThe spec documents on spec.openapis.orgSwagger UI, Swagger Editor, Swagger Codegen

What Is OpenAPI?

What is OpenAPI? It's a standard, language-neutral way to describe an HTTP API so that both people and programs understand it without reading the source code. An OpenAPI document (often openapi.yaml) lists the API's paths, the operations on each (GET, POST and so on), their parameters, request bodies, responses, data schemas and security schemes.

That single file then drives a lot of tooling:

  • Interactive documentation that lets readers try calls in the browser.
  • Client SDK generation in many languages.
  • Server stubs and request validation.
  • Mock servers for front-end teams to build against before the API exists.
  • Contract testing to catch changes that break clients.
  • API gateways that import routes and security rules.
  • AI agents and tools that read the description to learn how to call an API.

A minimal OpenAPI 3.1 document:

openapi: 3.1.0
info:
  title: Notes API
  version: 1.0.0
servers:
  - url: https://api.example.com/v1
paths:
  /notes/{id}:
    get:
      summary: Get a note
      parameters:
        - name: id
          in: path
          required: true
          schema: { type: string }
      responses:
        "200":
          description: The note
          content:
            application/json:
              schema: { $ref: "#/components/schemas/Note" }
components:
  schemas:
    Note:
      type: object
      required: [id, text]
      properties:
        id: { type: string }
        text: { type: string }

Is Swagger the Same as OpenAPI?

Is Swagger the same as OpenAPI? Not any more, though they share a history:

A horizontal timeline with six diamonds, the third in orange, a document at the start and a code window at the end
Swagger the specification became OpenAPI; Swagger the brand stayed with the tools.
WhenWhat happened
2010Tony Tam, then at Reverb Technologies (maker of Wordnik), releases the Swagger specification and tools
2015SmartBear, which now backed Swagger, forms the OpenAPI Initiative under the Linux Foundation (announced 5 November) and donates the specification
2016The specification is renamed the OpenAPI Specification; OAS 2.0 is the same as Swagger 2.0
July 2017OpenAPI 3.0.0 is released, the first version developed under the new name
February 2021OpenAPI 3.1.0 aligns schemas fully with JSON Schema and adds webhooks
September 2025OpenAPI 3.2.0 adds streaming media types, hierarchical tags, the QUERY method and the OAuth device flow

After the rename, "Swagger" refers to SmartBear's tooling. So a sentence like "we have a Swagger file" usually means an OpenAPI (or Swagger 2.0) document, and "Swagger page" usually means documentation rendered by Swagger UI.

The OpenAPI Specification: Versions Compared

The OpenAPI specification has moved on considerably since Swagger 2.0:

FeatureSwagger 2.0 / OAS 2.0OpenAPI 3.0OpenAPI 3.1OpenAPI 3.2
Version fieldswagger: "2.0"openapi: 3.0.xopenapi: 3.1.xopenapi: 3.2.x
Servershost, basePath, schemesservers list with variablesSameSame
Request bodyA body parameterrequestBody with per-media-type contentSameSame, plus streaming media types
Reusable partsdefinitions, parameters, responsescomponents (schemas, responses, parameters, examples, request bodies, headers, security schemes, links, callbacks)Same, plus path itemsSame, plus reusable media types
SchemasA subset of an old JSON Schema draftExtended subset of JSON SchemaFull JSON Schema 2020-12 compatibilitySame
Multiple content typesGlobal consumes and producesPer operation and responseSameSame
oneOf, anyOf, notNot supportedSupportedSupportedSupported
Callbacks and webhooksNoCallbacksCallbacks and top-level webhooksSame
Null valuesVendor extensionnullable: truetype: [string, "null"]Same

Key OpenAPI Terms

TermMeaning
DocumentThe whole description, usually one YAML or JSON file, sometimes split across files with references
PathA URL template such as /notes/{id}
OperationOne HTTP method on a path, such as GET /notes/{id}, with an optional operationId that code generators use as a function name
ParameterAn input in the path, query string, header or cookie
Request bodyThe payload sent with POST, PUT or PATCH, described per media type
ResponseA status code with its description, headers and body schema
SchemaThe shape of a piece of data, written in JSON Schema
ComponentA reusable definition referenced with $ref
TagA label that groups operations in documentation

Swagger 2.0 to OpenAPI 3: A Side-by-Side Example

Here's the same POST operation in both formats. Swagger 2.0:

swagger: "2.0"
host: api.example.com
basePath: /v1
schemes: [https]
consumes: [application/json]
paths:
  /notes:
    post:
      parameters:
        - in: body
          name: note
          required: true
          schema: { $ref: "#/definitions/Note" }
      responses:
        "201": { description: Created }
definitions:
  Note: { type: object, properties: { text: { type: string } } }

OpenAPI 3.1:

openapi: 3.1.0
servers:
  - url: https://api.example.com/v1
paths:
  /notes:
    post:
      requestBody:
        required: true
        content:
          application/json:
            schema: { $ref: "#/components/schemas/Note" }
      responses:
        "201": { description: Created }
components:
  schemas:
    Note: { type: object, properties: { text: { type: string } } }

The main moves when migrating are: host, basePath and schemes become servers; body parameters become requestBody; definitions move under components/schemas; global consumes and produces become per-operation content maps; and securityDefinitions become components/securitySchemes. Conversion tools handle most of this automatically, but review the output, especially for file uploads and polymorphic schemas.

Swagger UI and the Swagger Tools

A central document with an orange line and arrows out to a browser, a code window, a server and a checklist
One OpenAPI file feeds documentation, client and server code, mocks and tests.

Swagger UI is the best-known Swagger tool: it renders an OpenAPI document as interactive documentation where you can expand each endpoint and send test requests from the browser. Many frameworks bundle it. FastAPI, for example, generates an OpenAPI document from your code and serves Swagger UI at /docs automatically, as our comparison of FastAPI vs Flask shows.

ToolTypeWhat it does
Swagger UIOpen source (SmartBear)Interactive API documentation in the browser
Swagger EditorOpen source (SmartBear)Browser editor with live preview and validation
Swagger CodegenOpen source (SmartBear)Generates client libraries and server stubs
OpenAPI GeneratorOpen source (community fork of Swagger Codegen)Generates clients and servers for many languages
RedocOpen sourceThree-panel reference documentation
Scalar, Stoplight ElementsOpen source and commercialAlternative documentation renderers
SpectralOpen sourceLints OpenAPI files against style rules
Postman, InsomniaCommercial and free tiersImport OpenAPI files as request collections

None of these lock you in. Because OpenAPI is a standard, you can write one document and render it with Swagger UI today and Redoc tomorrow.

Design-First vs Code-First

There are two ways to produce an OpenAPI document:

Design-firstCode-first
HowWrite the OpenAPI file, review it, then implement the APIAnnotate or type your code; a framework generates the file
ProsAgreement before coding; front-end and back-end work in parallel; mocks from day oneNo duplicate source of truth; docs always match the code
ConsSpec and code can drift unless you validate against each otherAPI design gets shaped by implementation details
Common toolsSwagger Editor, Stoplight, plain YAML in GitFastAPI, NestJS, Spring (springdoc), ASP.NET, Go generators

Either works. The important part is keeping the document accurate, ideally by validating responses against it in tests.

Describing Authentication

OpenAPI documents also describe how clients authenticate, so documentation and generated clients handle it automatically. Schemes are defined once under components/securitySchemes and applied globally or per operation:

components:
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      bearerFormat: JWT
    apiKey:
      type: apiKey
      in: header
      name: X-API-Key
security:
  - bearerAuth: []

Supported types include API keys (in a header, query string or cookie), HTTP authentication such as Basic and Bearer, OAuth 2.0 flows with their scopes, OpenID Connect discovery and, since 3.1, mutual TLS. Swagger UI uses these definitions to show an "Authorize" button, so readers can try authenticated calls.

Keeping the Document Accurate

An OpenAPI file that doesn't match the API is worse than none, because clients and tests trust it. Practical ways to keep them in step:

  • Lint on every pull request with a tool such as Spectral, using rules for naming, descriptions, examples and error formats.
  • Detect breaking changes by diffing the new document against the last release; removed fields, new required parameters and changed types should fail the build or need sign-off.
  • Validate real traffic in tests: check that responses match the documented schemas, and that the server rejects requests the document says are invalid.
  • Generate where you can. Generating the document from code, or code from the document, removes one copy that could drift.
  • Version the document with the code in the same repository, and publish it with each release.

OpenAPI for AI Agents and Integrations

A good OpenAPI document has a new audience: software that reads it to call your API. Integration platforms import OpenAPI files to build connectors, API gateways use them to configure routes and validation, and many AI agent frameworks can turn an OpenAPI description into tools a language model can call. Clear operation summaries, parameter descriptions and examples help these tools as much as they help human readers.

The OpenAPI Initiative also maintains companion specifications: Arazzo for describing multi-step API workflows, and Overlay for applying repeatable changes to an OpenAPI document, such as adding descriptions for a public version.

OpenAPI and Other API Styles

OpenAPI describes REST-style HTTP APIs. Other styles use their own description formats: GraphQL APIs are described by their schema, gRPC by Protocol Buffers files, and event-driven APIs often by AsyncAPI. Our comparisons of REST vs GraphQL and gRPC vs REST cover when each style fits.

OpenAPI vs Swagger: Which Should You Use?

There's no real choice between them: you write an OpenAPI document, and you can use Swagger tools (or others) to work with it.

  • New API: use OpenAPI 3.1 for the widest tool support; adopt 3.2 features once your toolchain supports them.
  • Existing Swagger 2.0 file: migrate to OpenAPI 3.x when you next touch the API seriously, since newer tools increasingly expect it.
  • Documentation: Swagger UI for try-it-out docs; Redoc or Scalar for reference-style docs.
  • SDKs: OpenAPI Generator or a commercial SDK generator.
  • Quality: lint with Spectral and validate requests in CI.

Common Mistakes

  • Saying "Swagger" when you mean the spec version. Specify "OpenAPI 3.1" or "Swagger 2.0" so tools and teammates know what to expect.
  • Letting the document drift from the real API.
  • Overusing `additionalProperties: true` and loose schemas, which make generated clients weak.
  • Skipping examples. Good examples make documentation and mocks far more useful.
  • Assuming every tool supports every version. Check support for 3.1 and 3.2 before upgrading.

FAQ

Is Swagger still used?

Yes. Swagger UI, Swagger Editor and Swagger Codegen are widely used, and many older APIs still have Swagger 2.0 documents.

Is OpenAPI only for REST APIs?

It describes HTTP APIs, which in practice means REST-style APIs. GraphQL, gRPC and event-driven APIs use their own description formats.

Should I write OpenAPI in YAML or JSON?

Either is valid. YAML is easier for people to read and write; JSON is easier for some tools. Many teams author in YAML and convert to JSON when needed.

Can Swagger UI display OpenAPI 3.1?

Recent versions support OpenAPI 3.0 and 3.1. Check the release notes for your version, and for OpenAPI 3.2 support.

What is the difference between OpenAPI and an API schema?

An OpenAPI document describes the whole API: paths, operations, security and data. A schema usually means the shape of one data object, which OpenAPI defines using JSON Schema.

All articles

Read next

Language

EnglishEnglish · en TürkçeTurkish · tr DeutschGerman · de العربيةArabic · ar

Account

Enter your email. We’ll send you a sign-in link and a 6-digit code. No password needed.

Sign in

Theme

Language

Show our email address

To keep spam out of our inbox, please confirm your own email first. We will send you a 6-digit code.

We send codes only to these providers: gmail.com, googlemail.com, outlook.com, hotmail.com, live.com, msn.com, proton.me, protonmail.com, pm.me, icloud.com, me.com, mac.com, yahoo.com, aol.com, gmx.de, gmx.net, web.de, t-online.de, yandex.com, omniai.blog