Tutorial section for Mock Servers docs - #181
Conversation
|
Preview deployment for your docs. Learn more about Mintlify Previews.
|
anthonyd-bruno
left a comment
There was a problem hiding this comment.
I think we should call Mock Tutorial -> Getting Started
Mock with Response Examples -> Mock Servers from Collection
Mock with OpenAPI -> Mock Servers from OpenAPI
| description: "Walk through saving collection response examples, creating a mock server from them, syncing, adding rules, and serving the mock locally." | ||
| --- | ||
|
|
||
| Saved [response examples](/send-requests/res-data-cookies/response-examples) are snapshots of how an API behaves: success payloads, validation errors, empty lists, and other states you care about. Once they live on a request, you can document those cases, share them with the team, and with Mock Servers, serve them on `localhost` so a frontend or integration test does not need the real backend. |
There was a problem hiding this comment.
| Saved [response examples](/send-requests/res-data-cookies/response-examples) are snapshots of how an API behaves: success payloads, validation errors, empty lists, and other states you care about. Once they live on a request, you can document those cases, share them with the team, and with Mock Servers, serve them on `localhost` so a frontend or integration test does not need the real backend. | |
| [Response examples](/send-requests/res-data-cookies/response-examples) are snapshots of how an API behaves with success payloads, validation errors, empty lists, and other states you care about. Once they've been saved as an example, you can document those cases, share them with the team, and with Mock Servers, serve them locally so a frontend or integration test can immediately hit the endpoints without needing the real backend to be up and available. |
| Saved [response examples](/send-requests/res-data-cookies/response-examples) are snapshots of how an API behaves: success payloads, validation errors, empty lists, and other states you care about. Once they live on a request, you can document those cases, share them with the team, and with Mock Servers, serve them on `localhost` so a frontend or integration test does not need the real backend. | ||
|
|
||
| <Warning> | ||
| 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. |
There was a problem hiding this comment.
| 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. | |
| Mock Servers are in **Beta**. Open **Preferences → Beta** to turn on the **Mock Server** feature. The **Mock Servers** section appears in the sidebar only after you opt in. |
| 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. | ||
| </Warning> | ||
|
|
||
| ## Create response examples |
There was a problem hiding this comment.
This shows how to create a response example "from scratch". We should also show how to save a response as an example.
| Create at least one example per route you plan to mock. Multiple examples on the same method and path become alternative mock responses once you add [rules](/mock-servers/run-mock-server#rules). | ||
| </Tip> | ||
|
|
||
| ## Create a mock from collection examples |
There was a problem hiding this comment.
These look like sequential steps, so we should label them as such.
- Create or save response examples
- Create a Mock Server tied to a Collection
- Sync with examples
...
|
|
||
|  | ||
|
|
||
| Bruno opens the mock [dashboard](/mock-servers/run-mock-server#dashboard-interface-walkthrough). The server is not running yet — you still need to sync examples, then start it. |
There was a problem hiding this comment.
This is a really good landmark guide. Nice!
| | Match | Behavior | | ||
| |-------|----------| | ||
| | **All rules AND** (default) | Every condition must pass. | | ||
| | **Any rule OR** | One passing condition is enough. | |
There was a problem hiding this comment.
| | **Any rule OR** | One passing condition is enough. | | |
| | **Any rule (OR)** | One passing condition is enough. | |
|
|
||
|  | ||
|
|
||
| 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. |
There was a problem hiding this comment.
I would move the start server stuff to just above here.
There was a problem hiding this comment.
This is confusing for me, I would consider rephrasing.
"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."
|
|
||
| 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. |
There was a problem hiding this comment.
| **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. | |
| **Demo Request** is generated from the rules you defined. It shows a sample request that would select this response. |
The ending was a little confusing for me.
|
|
||
| ### Right section: expected body and headers | ||
|
|
||
| Use this side to define **what** the mock returns: the **Expected** body and **Headers**, plus the status code. |
There was a problem hiding this comment.
| Use this side to define **what** the mock returns: the **Expected** body and **Headers**, plus the status code. | |
| Use this side to see **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. |
There was a problem hiding this comment.
| **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. | |
| **Try Result** shows the response body and headers from **Expected** and **Headers** after you click **Try** (with the server running). |
bru.disableParsingResponseJson()method withreq.disableParsingResponseJson()with example