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.