Mock server
The mock server answers requests on http://localhost:4010 with canned responses, so a front end or another client
can be built and tested without the real API. Only this machine can reach it.
Right-click a folder or .http file and choose Mock server…. It opens in its own tab, where you can change the
port and Stop or Reload it. Then point an environment’s baseUrl at http://localhost:4010, and the same
.http files work against the mock too.


Routes
Section titled “Routes”Each request in the files becomes a route: its method, and its path.
- A
{{variable}}in the path matches any value, soGET {{baseUrl}}/pets/{{id}}answers/pets/7. - A base path inside the base URL variable is kept, using the selected environment. With
baseUrlset tohttps://host/api, the route is/api/pets/{{id}}.
A route answers with:
- The request’s snapshot, if it has one.
- Otherwise, its latest response this session.
Requests with neither are listed as not mocked. Send them, or press Snapshot, then press Reload.
OpenAPI descriptions
Section titled “OpenAPI descriptions”An OpenAPI description the files name (# @reqjet.openapi) adds a route for each operation. It answers with the
operation’s first success example, or with an example made up from its schema. A saved response wins over a made-up
one for the same route.
Other answers
Section titled “Other answers”- A path that isn’t mocked gets a 404 that lists the routes.
- A known path with another method gets a 405.
- A web app served from this machine, on any port (
http://localhost:3000,http://127.0.0.1:5173), can call it from the browser. Pages from other sites can’t read its responses, which can include real responses from your session, and requests addressed to any host other thanlocalhostare refused.
The tab logs every request the mock receives, and what it answered.
From the command line
Section titled “From the command line”reqjet mock runs the same server until you press Ctrl+C:
reqjet mock api/ --port 4010 --env dev # a folder's requestsreqjet mock openapi.yaml # an OpenAPI description on its ownreqjet mock orders.reqjet-workspace # every folder in a workspace