How to configure the WireMock CLI to record more specific stubs
filter
which controls whether the rule is applied to the generated stub. This is optional - if omitted the
template will always be applied.template
which generates request matchers to apply to the stubfilter
which matches the recorded request will be used to generate
matchers, which will be added in turn to the generated stub.
When more than one rule could both match and specify different matchers for the same element (for instance the first
specifies that the Content-Type
header is equalTo
"application/json"
, and the second that the Content-Type
header contains
"json"
), the last defined rule will win.
Finally a check is made that the generated stub would still match the recorded request from which it was generated. If
it would not the entire stub is discarded and no stub is generated at all for that request.
{{ recordedValue }}
macro may be used to capture what that value had
on the recorded request. For instance, the following rule:
{{ recordedValue }}
macro can be applied in the template, though
request matchers can be hard coded.
{{ recordedValue }}
macro cannot currently be used in an equalToJson
, equalToXml
or matching
request
matcher.
filter
only contains a request
matcher - it is not yet possible to apply rules conditionally based on the
response.
template
only contains a request
matcher - it is not yet possible to define changes to the response
definition in these rules.