Web apps & software

What is the OpenAPI specification?

The OpenAPI specification, formerly called Swagger, is a standard format for describing a REST API in a YAML or JSON file: its endpoints, parameters, request bodies, responses and authentication rules.

What the file contains

For each path, such as GET /bookings/{id}, it lists inputs, possible status codes and the shape of the data returned. Reusable components define objects like Booking or Driver once and refer to them everywhere.

What you can do with it

  • Generate interactive documentation where partners can try calls.
  • Create client libraries and server stubs in many languages.
  • Run contract tests that fail when the API drifts from its description.
  • Import it into Postman or an API gateway to set up routes and validation.

Design first or code first

Some teams write the specification before building so that front-end and back-end work in parallel. Others generate it from annotations in code. The second approach is easier to keep current; the first produces cleaner agreements.

Common failure

A specification that nobody updates is worse than none. Check it in CI.

Questions, answered

Swagger is the older name and also the name of a toolset. The specification itself is now called OpenAPI.

No. GraphQL has its own schema language.

By the Stegnor team · Updated