Using .http files to test API endpoints Part 1
The most popular development tools for testing API endpoints are Postman and Swagger. In Part 1 of this article I'm making the case for using .http files.
Modern API development involves constant iteration: write an endpoint, test it, tweak it, test again. Most teams default to Postman or Swagger UI because they’re familiar, visual, and easy to start with. But they also create a split workflow: the code lives in Git, while the tests live in a GUI tool or a browser tab. .http files solve that split by embedding API testing directly into the codebase.
Here are a few reasons for using them:
-
They can live in the source repository — unlike Postman collections or Swagger UI sessions, .http files sit alongside the code, versioned, reviewed, and shared naturally.
-
They reduce context switching — no jumping between browser tabs, Postman windows, or exported collections. Everything happens in your code editor.
-
They are transparent and text-based — easy to diff, easy to understand, easy to automate.
-
They support advanced workflows - chaining, scripting, assertions, and environment handling become part of the development loop rather than an external tool.
-
Postman is GUI-first — great for exploration, but harder to version, review, or automate.
-
.http files are code-first — they behave like source code, not like a separate artefact.
-
Postman collections drift — teams often forget to update them, or they live on one developer’s machine.
-
.http files stay in sync — they evolve with the code because they live next to it.
-
Swagger UI is generated from the API spec, not from the actual code or tests. It’s a consumer-facing tool, not a developer workflow.
-
Swagger encourages a “click to test” model, which is useful for demos but slow for repeated testing.
-
Swagger does not support scripting, chaining, or assertions, which are essential for real development workflows.
-
.http files complement OpenAPI, because you can still use the spec for documentation while using .http files for real testing.
-
.http files turn API testing into a first-class part of the development workflow. Instead of relying on external tools like Postman or Swagger UI, developers can write, run, script, and version their API tests directly inside VS Code. This article explores how to use .http files effectively, using the HttpYac ecosystem.
