How can I make query parameter(pageSize) in below json as optional while using wiremock
{
"request": {
"method": "GET",
"urlPath": "/claims-search",
"queryParameters" : {
"pageSize" : {
"equalTo" : "10"
},
"pageNumber" : {
"equalTo" : "2"
}
}
},
"response": {
"status": 200,
"bodyFileName": "response_200.json",
"headers": {
"Content-Type": "application/json"
}
If you don't care about what value the query parameters have, you can simply exclude them.
If you need them under certain circumstances, you can use the Or operator to include an absent flag. In your case, it'd look something like...
{
"request": {
"method": "GET",
"urlPath": "/claims-search",
"queryParameters" : {
"pageSize" : {
"or": [{
"equalTo" : "10"
}, {
"absent": true
}]
},
"pageNumber" : {
"or": [{
"equalTo" : "10"
}, {
"absent": true
}]
}
}
},
"response": {
"status": 200,
"bodyFileName": "response_200.json",
"headers": {
"Content-Type": "application/json"
}
}
}
I think this functionality was introduced in WireMock 2.29.0.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With