Skip to main content
An OpenAPI document already describes paths, methods, status codes, and response schemas. Bruno can turn that contract into a local mock so frontend and integration work can start before the real service exists or continue when the backend is unavailable. This tutorial loads a spec into Bruno, creates a spec-linked mock, generates responses from operations, and starts the server.
Mock Servers are in Beta. Open Preferences → Beta and turn on Mock Server. The Mock Servers section appears in the sidebar only after you opt in.

Open an OpenAPI spec

Bruno can view and work with existing OAS files. Full steps, including screenshots, are in Viewing Existing OAS Files.
  1. Open Preferences → Features and enable API Spec.
  2. An API Spec section appears in the Bruno sidebar.
  3. Click + in that section, choose Open API Spec, and pick a .yaml or .json file from disk.
  4. The spec appears in the sidebar. Click it to open the viewer.
OpenAPI spec open in the Bruno API Designer Keep the spec in the workspace so the mock can stay linked to it.

Create a mock from the spec

  1. Enable Mock Servers under Preferences → Beta if they are not already on.
  2. Click the + icon next to Mock Servers in the sidebar.
  3. Enter a name. Set the source to API Spec and select the spec you want to generate from.
  4. Optionally open Advanced settings to set the port and response delay (ms).
  5. Click Create.
Create Mock Server dialog with API Spec as the source Bruno opens the mock dashboard. Responses are not generated until you run Generate from API Spec. Spec-linked mock server dashboard with no responses yet

Generate from API Spec

On the Responses tab you get two entry points:
  • New Mock Response - a blank mock you fill in yourself.
  • Generate from API Spec - one mock response per operation and status in the spec. Bodies come from examples in the spec when present, otherwise from the schema where Bruno can derive them.
Click Generate from API Spec. Generated items appear on the Responses tab. Search to jump to a path or operation name. Responses tab populated with mock responses generated from the spec
Specs that define several status codes for one operation (for example 200 and 400) produce several mock responses on the same route. Add rules if you want the mock to pick among them instead of always returning the default.

Sync with Spec

If the OpenAPI file changes, use Sync with Spec. Bruno re-imports the spec and updates responses that still match an operation (method and path). Custom responses you added or changed stay in place. Use this after you add endpoints, rename paths, or update example payloads in the spec.

Start the server

Click Start Server in the dashboard header. The first start uses port 4000 unless you set another port in Advanced settings. Call the mock at http://localhost:<port> plus the operation path. Change the port later from Mock Server Settings (gear icon).

Response Editor

Each mock response opens in an editor with two side-by-side sections:
  • Left: rules, demo request, response URL, Try button, and Open as New Request button (when to return this response)
  • Right: expected body, headers, and try results (what the response should look like)
Mock response editor for a response generated from the spec Generated spec responses use the same editor as any other mock. If one operation has several statuses (200 and 400, for example), open each response and add rules so the mock can choose among them.

Left section: rules and demo request

Use this side to decide when this response is returned. After you start the server, each mock API is available at http://localhost:4000 plus the operation path, unless you changed the port in Advanced settings. Change the port later from Mock Server Settings (gear icon).

Rules

To add matching logic, click Add rule or the Edit icon (top-right of the response). The Rules and Demo Request sections appear. See Rules on the dashboard guide for field-level detail. You can match on body, headers, and query parameters so the same path can return different payloads (admin vs guest, missing field vs valid body, and so on). Match controls how those conditions combine: After you add or change rules, click Save in the top-right of the editor. Rules are not applied until you save. Rules editor for a spec-generated mock response With the mock server running, click Try next to the response URL to send the demo request. Open the Try Result tab on the right: it shows only the body and headers you defined in Expected and Headers. Anything not set there will not appear in Try Result. Demo Request is generated from the rules you defined. It shows a sample request that would select this response, so you can copy it into a client or use Try while the server is running. Open as New Request opens the demo request in a new request tab with the rules and demo request applied.

Right section: expected body and headers

Use this side to define what the mock returns: the Expected body and Headers, plus the status code. The body can be JSON, HTML, text, or XML. Headers are independent of body type — set Content-Type and any other headers the client should see. Try Result shows the response body and headers from Expected and Headers after you click Try. Only those values appear — the tab does not invent extra fields.

Inspect traffic

After the server is running:
  • Routes - registered method and path combinations from the spec (and any extra responses you added), plus hit counts.
  • Request Log - each incoming request, the selected mock (or No Match), and the Match Trace Inspector when a rule did not behave as expected.
See the dashboard walkthrough for delay, refresh, copy URL, and filters.

Next steps