setup_replay
Record a service's response once, then replay it for matching requests to stabilize API mocks. Configure recording scope, match fields, and upstream source, then restart to apply.
Instructions
Configure replay for a service: record a real response once, then serve it back for every matching request (VCR). Writes a replay: block into the service's config.yml.
ASK THE USER TWO THINGS BEFORE CALLING:
Record from a real backend, or pin the mock's own output? With
upstream_urlthe recording is the real backend's response. Without it, replay pins the generated response so repeat calls stop returning fresh random data, which is often what 'make it stable' means.One recording for the whole endpoint, or one per input? With no
matchfields the key is method and path only, so EVERY call to POST /foo replays the first response no matter what it sends. Look at what the endpoint actually takes, then ask which fields distinguish one case from another and pass those asmatch.
Match fields come from three sources: path (path variables, ignored unless listed), body (dotted paths like data.items[0].name, or "[0].name" for a top-level array, or flat keys for form bodies), and query. Returns recording_scope spelling out what each endpoint is keyed by. Only writes inside the bridge's own mocks dir; for a folder served from the user's project it returns the YAML and the path for them to apply. Config is read at startup, so restart after.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| dir | No | Directory holding the service, when it is not one of the bridge's own mocks. | |
| service | Yes | Service to record, as named in serve_locally's output. | |
| duration | No | How long recordings live, e.g. "24h". | |
| endpoints | Yes | Endpoints to record. | |
| auto_replay | No | Record and replay without the X-Mockzilla-Replay header. | |
| upstream_url | No | Real backend to record from, e.g. "https://api.example.com". Omit to record the mock's own generated responses. | |
| upstream_only | No | Refuse to record anything that did not come from the upstream. Needs `upstream_url`, or every request answers 502. |