<!-- mobian-agent-page publisher="dailydev" canonical="https://daily.dev/posts/how-to-create-a-mock-server-from-an-openapi-spec-in-bruno-vjyj50vpe" -->

---
title: How to Create a Mock Server from an OpenAPI Spec in Bruno
description: Bruno can generate a local mock server directly from an OpenAPI spec, so teams can test against a contract before the real backend exists. The workflow is...
canonical: https://daily.dev/posts/how-to-create-a-mock-server-from-an-openapi-spec-in-bruno-vjyj50vpe
twitter:card: summary_large_image
twitter:site: @dailydotdev
og:type: website
og:site_name: daily.dev
og:title: How to Create a Mock Server from an OpenAPI Spec in Bruno | daily.dev
og:description: Bruno can generate a local mock server directly from an OpenAPI spec, so teams can test against a contract before the real backend exists. The workflow is...
og:url: https://daily.dev/posts/how-to-create-a-mock-server-from-an-openapi-spec-in-bruno-vjyj50vpe
og:image: https://api.daily.dev/og/posts/VjYj50Vpe.png
og:image:alt: How to Create a Mock Server from an OpenAPI Spec in Bruno
og:image:width: 1200
og:image:height: 630
og:locale: en
---

> ## Documentation Index
> Fetch the complete documentation index at: https://daily.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# How to Create a Mock Server from an OpenAPI Spec in Bruno

**[Bruno Blog](https://daily.dev/sources/usebruno)** · [@devgancode](https://daily.dev/devgancode) · 11 min read · 1 upvotes · 0 comments

## Summary

Bruno can generate a local mock server directly from an OpenAPI spec, so teams can test against a contract before the real backend exists. The workflow is create, generate, then start: Bruno creates one mock response per operation and status, using spec examples or deriving bodies from the schema. The default port is 4000, and the server runs at a localhost URL you can curl, like 'curl http://localhost:4000/pet/1'. A 'Sync with Spec' action re-imports the file later and preserves custom responses while updating ones that still match by method and path. Mock Servers are currently in beta.

## Full article

daily.dev links to this article rather than hosting it. Read it at the original source: <https://blog.usebruno.com/create-mock-server-from-openapi-spec-bruno>

## Questions this post answers

### How do I create a mock server from an OpenAPI spec in Bruno?

Enable API Spec under Preferences, Features, then open your .yaml or .json spec file in the API Spec sidebar section. Create a new mock server, select API Spec as the source, then click 'Generate from API Spec' to create one mock response per operation and status, and finally click 'Start Server' to run it, defaulting to port 4000.

_daily.dev surfaces guides like this for developers building contract-first API workflows._

### How do I handle an OpenAPI operation that documents both a 200 and a 400 response in a Bruno mock server?

Generating from the spec creates separate mock responses for each documented status on the same method and path, but the mock keeps returning only the default response until you add rules. Open the response editor, add a rule based on body, headers, or query conditions, and save it to make the mock pick between statuses on the same route.

_Teams building contract tests around branching status codes can track workflow details like this on daily.dev._

### What happens to my custom mock responses when I sync a Bruno mock server with an updated OpenAPI spec?

Custom responses added manually are preserved during a sync. Bruno re-imports the spec and updates only the generated responses that still match an operation by method and path, but a sync can overwrite a generated response you heavily edited if its corresponding spec example also changed.

_Developers keeping mocks in sync with evolving API contracts can follow updates like this on daily.dev._

## Similar posts on daily.dev

- [How to Create Mock Servers from Collection Response Examples in Bruno](https://daily.dev/posts/how-to-create-mock-servers-from-collection-response-examples-in-bruno-rarjyq7um) · Bruno Blog · 0 upvotes · 0 comments
- [How-tos & Examples](https://daily.dev/posts/how-tos-examples-cxl03k9wm) · Hacker News · 0 upvotes · 0 comments
- [That mockingbird won't sing: a mock API server in Rust — Bitfield Consulting](https://daily.dev/posts/that-mockingbird-won-t-sing-a-mock-api-server-in-rust-bitfield-consulting-fyjhiehge) · Bitfield Consulting · 0 upvotes · 0 comments
- [A 3rd-Party Notion API Sandbox to Provide a Safer Agent Sandbox](https://daily.dev/posts/a-3rd-party-notion-api-sandbox-to-provide-a-safer-agent-sandbox-jxk4u7nnf) · API Evangelist · 1 upvotes · 0 comments
- [How to Test an API Without a Frontend](https://daily.dev/posts/how-to-test-an-api-without-a-frontend-5phbkfhlw) · Bruno Blog · 16 upvotes · 3 comments

---

Tags: [#testing](https://daily.dev/tags/testing), [#openapi](https://daily.dev/tags/openapi)

[View this post on daily.dev](https://daily.dev/posts/how-to-create-a-mock-server-from-an-openapi-spec-in-bruno-vjyj50vpe)

```json
{"@context":"https://schema.org","@graph":[{"@type":"Organization","@id":"https://daily.dev/#organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180},"sameAs":["https://twitter.com/dailydotdev","https://github.com/dailydotdev","https://www.linkedin.com/company/daily-dev-ltd"]},{"@type":"WebSite","@id":"https://daily.dev/#website","url":"https://daily.dev","name":"daily.dev","publisher":{"@id":"https://daily.dev/#organization"},"potentialAction":{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https://daily.dev/search?q={search_term_string}"},"query-input":"required name=search_term_string"}}]}
{"@context":"https://schema.org","@type":"TechArticle","headline":"How to Create a Mock Server from an OpenAPI Spec in Bruno","url":"https://daily.dev/posts/how-to-create-a-mock-server-from-an-openapi-spec-in-bruno-vjyj50vpe","mainEntityOfPage":{"@type":"WebPage","@id":"https://daily.dev/posts/how-to-create-a-mock-server-from-an-openapi-spec-in-bruno-vjyj50vpe"},"datePublished":"2026-10-27T11:33:52.790Z","dateModified":"2026-10-28T08:00:47.569Z","description":"Bruno can generate a local mock server directly from an OpenAPI spec, so teams can test against a contract before the real backend exists. The workflow is...","image":"https://media.daily.dev/image/upload/f_auto,q_auto/v1/posts/2f7b47f7facb797dea64be7d340d673d?_a=AQAEuop","thumbnailUrl":"https://media.daily.dev/image/upload/f_auto,q_auto/v1/posts/2f7b47f7facb797dea64be7d340d673d?_a=AQAEuop","isAccessibleForFree":true,"articleSection":"Bruno Blog","inLanguage":"en","publisher":{"@type":"Organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180}},"author":{"@type":"Person","name":"Ganesh Patil","url":"https://daily.dev/devgancode","image":"https://media.daily.dev/image/upload/s--YZDsshgS--/f_auto/v1723695126/avatars/avatar_DKBm9qlNzn7jbRNc8qWlD","interactionStatistic":{"@type":"InteractionCounter","interactionType":{"@type":"EndorseAction"},"userInteractionCount":60}},"commentCount":0,"discussionUrl":"https://daily.dev/posts/how-to-create-a-mock-server-from-an-openapi-spec-in-bruno-vjyj50vpe","interactionStatistic":[{"@type":"InteractionCounter","interactionType":{"@type":"LikeAction"},"userInteractionCount":1},{"@type":"InteractionCounter","interactionType":{"@type":"CommentAction"},"userInteractionCount":0}],"keywords":"testing,openapi","timeRequired":"PT11M"}
{"@context":"https://schema.org","@type":"BreadcrumbList","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https://daily.dev"},{"@type":"ListItem","position":2,"name":"Bruno Blog","item":"https://daily.dev/sources/usebruno"},{"@type":"ListItem","position":3,"name":"How to Create a Mock Server from an OpenAPI Spec in Bruno"}]}
{"@context":"https://schema.org","@type":"FAQPage","@id":"https://daily.dev/posts/how-to-create-a-mock-server-from-an-openapi-spec-in-bruno-vjyj50vpe#faq","mainEntity":[{"@type":"Question","name":"How do I create a mock server from an OpenAPI spec in Bruno?","acceptedAnswer":{"@type":"Answer","text":"Enable API Spec under Preferences, Features, then open your .yaml or .json spec file in the API Spec sidebar section. Create a new mock server, select API Spec as the source, then click 'Generate from API Spec' to create one mock response per operation and status, and finally click 'Start Server' to run it, defaulting to port 4000. daily.dev surfaces guides like this for developers building contract-first API workflows."}},{"@type":"Question","name":"How do I handle an OpenAPI operation that documents both a 200 and a 400 response in a Bruno mock server?","acceptedAnswer":{"@type":"Answer","text":"Generating from the spec creates separate mock responses for each documented status on the same method and path, but the mock keeps returning only the default response until you add rules. Open the response editor, add a rule based on body, headers, or query conditions, and save it to make the mock pick between statuses on the same route. Teams building contract tests around branching status codes can track workflow details like this on daily.dev."}},{"@type":"Question","name":"What happens to my custom mock responses when I sync a Bruno mock server with an updated OpenAPI spec?","acceptedAnswer":{"@type":"Answer","text":"Custom responses added manually are preserved during a sync. Bruno re-imports the spec and updates only the generated responses that still match an operation by method and path, but a sync can overwrite a generated response you heavily edited if its corresponding spec example also changed. Developers keeping mocks in sync with evolving API contracts can follow updates like this on daily.dev."}}]}
```

