Hi All, Not sure if this is a possibility. Can we ...
# general
s
Hi All, Not sure if this is a possibility. Can we do a if condition in wiremock mapping to pick the response body based on a certain input value(s)
a
Like a request query parameter or request body value?
s
Its based on the request body value
a
Yep! So you can take the values from the request body and use that to determine what your response body or bodyFile is
One sec, I’ll get an example
So, the following mapping:
Copy code
{
  "request": {
    "url": "/test"
  },
  "response": {
    "status": 200,
    "bodyFileName": "{{ jsonPath request.body '$.filename'}}.json"
  }
}
Will return the value of the
filename
key in the request body. So, a request with a body like
{ filename: "test" }
, would resolve to
test.json
, and serve up the file at
__files/test.json
.