What is Swagger (SmartBear)?
Swagger is SmartBear’s family of tools for working with OpenAPI definitions. The name predates the standard: the Swagger Specification was donated to the OpenAPI Initiative under the Linux Foundation in 2015 and became the OpenAPI Specification, so “Swagger 2.0” and “OpenAPI 2.0” are the same format, and everything from OpenAPI 3.0 onward is governed by the OpenAPI Initiative, not by SmartBear. What remains under the Swagger name is tooling: the open-source Swagger Editor, Swagger UI and Swagger Codegen, supporting libraries such as Swagger Core and Swagger Parser, and a commercial platform (SwaggerHub and related products) that adds hosted design, governance, portals, and functional and contract testing.
Why use it in the API Lifecycle?
- Swagger UI: Renders an OpenAPI or AsyncAPI definition as interactive reference documentation with a “Try it out” console. It is embedded in a large number of frameworks as the default
/docspage, which makes it the format many API consumers recognize. - Swagger Editor: A browser-based editor with validation and a live preview, useful for editing a definition by hand and seeing what it renders as.
- Swagger Codegen: Generates client SDKs and server stubs from a definition. The community fork OpenAPI Generator, split off in 2018 and is maintained separately by its own community; compare both before choosing.
- Swagger Core and Parser: Java libraries for producing a definition from annotated code and for parsing and resolving definitions in your own tooling.
- Commercial platform: Central hosting of definitions, style-rule enforcement, developer portals, and functional and contract testing, for teams that want those as a managed service.
Best Practices
- Name the format correctly. Call the document an OpenAPI definition and specify the version (
openapi: 3.1.0); “Swagger” in a field name, file name or job title tells readers nothing about which version is meant, and 2.0 and 3.x differ in structure. - Do not ship Swagger UI’s “Try it out” against production with real credentials by default. Point the
serversentry at a sandbox, and if the console must be enabled, restrict it withsupportedSubmitMethods(an empty array disables the console for every operation, or list onlyget) so a reader cannot fire aDELETEat live data from the docs page. - If Swagger UI is served from a different origin from the API, the browser makes real cross-origin requests from the console, so the API needs a correct CORS configuration, including
Access-Control-Allow-HeadersforAuthorization. Widening CORS just to make the docs console work is a security decision, not a docs fix. - Treat the definition as the source of truth and make the rendered docs a build artifact: lint the definition in CI with Spectral or vacuum, then publish Swagger UI from the linted file. See Design-First and Governance.
- Document error responses, not only the happy path. A definition that lists only
200renders docs that hide every failure; describe theapplication/problem+jsonshape for4xxand5xxresponses so both the docs and generated clients handle them. - Before generating SDKs, decide between Swagger Codegen and OpenAPI Generator per language by reading the generated code, and pin the generator version so a regeneration does not silently change the client’s public API. SDK Generation covers the trade-offs.