← Blog

Swagger vs Postman: the difference, and how to use them together

Short answer: Swagger describes an API; Postman calls it. "Swagger" means the OpenAPI specification (a file listing every endpoint of a service, its parameters and responses) plus the tools built around it, above all Swagger UI, the documentation page with the Try it out button. Postman is an API client: you send requests from it and keep collections, environments, history and tests there. They don't compete: teams usually turn the spec into a collection for the client.

Most teams use both: the spec serves as the contract and the docs, and everyday calls go through the client. And "one describes, the other sends" is only nearly right: Swagger UI can send requests too.

Swagger and OpenAPI: the same thing?#

Close. Since 2016 the format has been called the OpenAPI Specification; the Swagger name now belongs to SmartBear's tools. Swagger itself appeared in 2011 as a format for describing REST APIs, and in late 2015 it was handed to the OpenAPI Initiative under the Linux Foundation. The older version goes by both names: Swagger 2.0 and OpenAPI 2.0.

SmartBear's tools under that name:

  • Swagger UI renders a spec as interactive documentation;
  • Swagger Editor helps you write a spec and see the result as you type;
  • Swagger Codegen generates client and server code from it.

So when a team says "we have Swagger", it usually means there's an openapi.json or openapi.yaml somewhere, and a URL like /swagger opens a documentation page.

One spec. Swagger UI shows it as documentation; an API client turns it into a collection to work with

Can you test an API in Swagger UI?#

Yes, by hand and one request at a time. Swagger UI is good for browsing an API. Every operation, its parameters and example responses sit on one page. Click Try it out, fill in the fields, hit Execute, and the request goes straight from your browser to the server. There's an Authorize button for the token.

That's enough for a one-off check. Use it every day and the gaps show quickly:

  • Nothing is saved. You can't keep a request with its parameters filled in and come back to it tomorrow, and there's no response history. By default even the token you entered in Authorize is gone after a page reload.
  • No environments. Trying the same request on staging and production means another page or another spec.
  • No chaining, no tests. You can't take the token from a login response and feed it into the next request, or check that a response has the field you expect.
  • The browser sends the request. If the docs aren't served from the same origin as the API, the server has to allow cross-origin requests (CORS), or Try it out fails even though the API itself is fine.

API clients handle all of that: Postman, Insomnia, Bruno, Tetiva.

Swagger vs Postman: comparison table#

Swagger (OpenAPI + Swagger UI)Postman and other API clients
What it isA description of the API and its docsAn app for sending requests
Usually made byBackend developers, often generated from codeAnyone who checks the API: developers, QA, analysts
Lives inA file in the repo and a page on the serverCollections in the app or the cloud
Sends requestsYes, from the browser, one at a timeYes, with saved parameters
Environments: dev, stage, prodNoYes
History and saved requestsNoYes
Tests and scriptsNoYes
The question it answersWhich endpoints exist and what they acceptWhat the server returns for this exact request

How they work together#

How it usually goes in a team:

  1. The backend describes the API in code, and the framework generates the spec from it.
  2. Swagger UI shows that spec to everyone as documentation.
  3. QA, frontend and analysts import the spec into an API client and work there: saving requests, setting up environments, writing checks.
  4. When the API changes, they import the spec again.

Nobody retypes paths and field names from the docs, so there are fewer typos. Keep in mind that re-importing usually creates a new collection next to the old one, so your checks and filled-in values have to be carried over by hand.

Where to find the spec file#

Swagger UI usually links the file right under the page title. If it doesn't, here's where popular frameworks put it by default:

FrameworkDocsSpec
FastAPI (Python)/docs/openapi.json
Spring Boot with springdoc/swagger-ui.html (redirects to /swagger-ui/index.html)/v3/api-docs
ASP.NET with Swashbuckle/swagger/swagger/v1/swagger.json
NestJSwherever it was set up, e.g. /api/api-json

Projects can change these paths. If they did, ask the backend team, or open the Network tab in developer tools on the docs page: Swagger UI fetches the spec as a separate request, and its URL will be in the list.

How to import Swagger into Postman or another client#

Postman

  1. Click Import: it's in the sidebar, or under Use resources or import on the workspace page.
  2. Drop in openapi.json or openapi.yaml, or paste its URL. You can try this with the public Petstore spec.
  3. Postman recognizes OpenAPI and offers to import it as a Postman Collection or as a Specification with a Postman Collection; the plain collection is enough for a try. In the import settings you can group requests into folders by tag instead of by path.
  4. Click Import. The server URL ends up in a baseUrl collection variable, and path parameters become :petId-style variables. Petstore's server URL is relative (/api/v3), so set baseUrl to https://petstore3.swagger.io/api/v3 before sending anything.

Tetiva

  1. Click Import File… above the collection tree and pick openapi.json or openapi.yaml. OpenAPI 3.0 and 3.1 and Swagger 2.0 all work. If the spec only exists at a URL, save it to disk first.
  2. The confirmation window shows how many folders, requests and examples you'll get, which environment is added, which hosts the requests go to, and what won't come across. If the spec's server URL is relative, as Petstore's is, the window warns you and asks for the full address in baseUrl.
  3. Click Import. The environment with the server URL becomes active right away: add a token and send the request.
What goes where: a tag becomes a folder, a path parameter a variable, the server URL a baseUrl variable in an environment

What the import does:

  • each operation's first tag becomes a folder, and the operation a request named after its summary or operationId;
  • path parameters such as {petId} become {{petId}} variables;
  • the request body comes from the spec's example, or is generated from the schema;
  • auth comes from securitySchemes: Bearer, Basic, Digest, API key, OAuth 2.0;
  • example responses are saved next to the requests;
  • an environment named after the API appears, holding the first server's URL, the path parameters and empty slots for tokens.

External $refs, callbacks, webhooks and links don't come across; the full list is in the import docs.

Checking that the API still matches the spec#

Specs and servers drift apart: a field gets renamed, a number turns into a string, and nobody updates the docs. Swagger UI puts the documented example and the real response on one page, but you have to spot the differences yourself.

To compare a response in Tetiva, send the request, click the arrow next to Compare in the status line and pick the example from the spec: it's named after the status code, such as 200 OK. It opens next to the current response with the differences highlighted. Normalize JSON is on from the start: keys are sorted and timestamps ignored.

The spec's example and the real response: a number became a string, and status was renamed to state

If the spec has no example for a successful JSON response, Tetiva builds one from the schema. Its values are placeholders, so look at field names and types. More on comparing in the response viewer docs.

And the other way, from a collection to a spec?#

Sometimes there's a collection but no spec, and you'd like documentation out of it. You can, but you get a draft: a collection holds requests and example responses, not schemas or required fields, so those have to be written by hand. That's why it's better to generate the spec from the service's code, so it matches what the API actually does. Tetiva doesn't do this export; it writes collections only as Postman v2.1.

Can Postman replace Swagger?#

Partly. Postman can import and edit an OpenAPI spec, publish documentation from a collection and run mock servers, so a team that lives in Postman may never open Swagger UI. The spec itself still matters: if it's generated from code, it's the reference the collection is built from.

Which to reach for#

  • To learn what an API can do: open Swagger UI.
  • To call an endpoint once: Try it out is enough.
  • To work with the API every day, across several environments, keeping requests and sharing them with the team: import the spec into an API client.
  • When the spec changes: import it again instead of fixing requests by hand.
  • To check the API still matches the spec: compare a response with the spec's example; in Tetiva that's the Compare button.