Mock server
The mock server answers requests on your Mac with responses from your history or from an OpenAPI file. Use it to build a front end before the API exists, or to test without hitting a real server.
Start a mock server
Section titled “Start a mock server”Press ⌘K and choose Mock server (from History or an OpenAPI file)…. Pick where responses come from:
- History: the latest response for each method and path, with its status, content type and body.
- An OpenAPI file: the first 2xx response’s example for each operation, or a sample built from the schema when there’s no example.
The server listens on http://127.0.0.1:<port>, on your Mac only.
How requests are matched
Section titled “How requests are matched”- Path parameters match any value. Exact paths win.
- Each route can wait a set time before answering, to simulate a slow API.
- Unknown paths get a
404that lists the available routes.
The log shows each request the mock server receives. The server stops when you close the folder.
From the command line
Section titled “From the command line”courier mock api.openapi.yaml --port 4010 --delay 200The CLI serves OpenAPI examples until you press CtrlC. --port 0 picks a free port.