Responses
The response object of a stub describes what is served once the request pattern
matches.
"response": { "status": 201, "statusMessage": "Created", "headers": { "Content-Type": "application/json" }, "jsonBody": { "id": 1, "status": "created" }}Status and headers
| Field | Notes |
|---|---|
status | HTTP status code |
statusMessage | Served as the HTTP reason phrase on the wire |
headers | Single- or multi-value |
Body fields
Three fields can carry a body. If more than one is present, they are applied in this order:
| Order | Field | Type |
|---|---|---|
| 1 | body | string |
| 2 | jsonBody | object |
| 3 | base64Body | base64 string |
body wins over jsonBody, and jsonBody wins over base64Body. Set exactly one to avoid ambiguity.
Templating
Add "transformers": ["response-template"] to a response to make its body and headers Handlebars
templates. To enable it for every stub on the host, start the server with
--global-response-templating.
"response": { "status": 200, "transformers": ["response-template"], "jsonBody": { "echo": "{{jsonPath request.body '$.name'}}" }}See templating for the model and template helpers for the full helper reference.
Behaviour fields
These also live on response and each has its own page.
| Field | Page |
|---|---|
fixedDelayMilliseconds | delays and faults |
delayDistribution | delays and faults |
fault | delays and faults |
proxyBaseUrl | proxying |
additionalProxyRequestHeaders | proxying |
proxyUrlPrefixToRemove | proxying |
Compression
A response is gzipped when the request carries Accept-Encoding: gzip, regardless of the response
content type. There is no per-content-type exclusion list.
Output shape quirks
Some rendered output is formatted in ways that look inconsistent on their own. These shapes are preserved deliberately, because WireMock produces them and differential parity is the definition of correct here.
| Case | Rendered as |
|---|---|
jsonPath result that is an object | Jackson-pretty (indented) |
jsonPath result that is a top-level array | Compact |
toJson output containing arrays | Spaced |