Monazza Khokhar
05/30/2024, 10:27 PMBas Dijkstra
05/31/2024, 6:09 AMLee Turner
05/31/2024, 8:33 AMMQ
and include the Foo
field in the response and the other stub won't include the field.
If that isn't possible you could just wrap the if
around the whole field to determine whether it is included or not:
{
"status": "OK",
{{#if (contains request.headers.bar.0 'MQ')}}
"Foo": "Q",
{{/if}}
"message": "Hello"
}
Monazza Khokhar
05/31/2024, 3:13 PMBas Dijkstra
05/31/2024, 3:21 PM{
"mappings": [
{
"request": {
"method": "GET",
"url": "/something",
"headers": {
"bar": {
"contains": "MQ"
}
}
},
"response": {
"status": 200,
"body": "response_including_foo"
}
},
{
"request": {
"method": "GET",
"url": "/something",
"headers": {
"bar": {
"doesNotContain": "MQ"
}
}
},
"response": {
"status": 200,
"body": "response_without_foo"
}
}
]
}
Or am I missing something here?Lee Turner
05/31/2024, 3:24 PMThe second approach doesn’t work inside my response.json file as it expects property:value pair and you can’t write if statements beforeThis only doesn't work in your file because your response file is a json file. You are wanting to send a json response but that doesn't mean your response file has to be json. Wiremock will still handle it fine even if your IDE/editor shows that there are errors in the json due to the handlebars
Lee Turner
06/01/2024, 12:52 PM.txt
extension which would remove the errors from my editor and WireMock would still handle it fine