What is OpenAPI (Swagger), and how does it help in documenting and contracting a REST API?

Last updated 29 June 2026

  • OpenAPI (formerly Swagger) is a language-agnostic, machine-readable spec (YAML/JSON) describing endpoints, parameters, schemas, auth, and status codes as one shared contract.

  • The same spec drives tooling: interactive docs (Swagger UI, Redoc), generated SDKs, server stubs, mock servers, and contract tests in CI.

  • "Swagger" now names the tooling ecosystem while "OpenAPI" is the standard (3.x). Frameworks like FastAPI auto-generate it at /openapi.json to keep docs in sync.

  • https://swagger.io/open-api/
  • https://www.ibm.com/think/topics/open-api
  • https://swagger.io/docs/
  • https://solaimanshadin.medium.com/contract-first-api-development-with-openapi-d13c8c419790
  • https://medium.com/@mk8961052/openapi-documentation-a-contract-between-frontend-and-backend-fff5139cfe66
  • https://swagger.io/docs/specification/v2_0/what-is-swagger/
  • https://swagger.io/blog/api-documentation-made-easy-with-openapi-and-swagger/
  • https://swagger.io/docs/specification/v3_0/about/
All REST API interview questions