How we can ignore the order of query parameter in WireMock

4.4k Views Asked by At

Suppose I have endpoint: /url?number="321"&name="TEST" but when we are matching a request matching how we want to ignore the order of query parameter(ignore order of query param)

In this case if pass query param in query param tag then I will not distinguish between request, because same endpoint but multiple query param.

1

There are 1 best solutions below

2
On

In the documentation the section on Regular Expression shows the example for matching on Query Parameters. It is even possible to include the absence of a parameter.

Using your example it might look like:

{
  "request" : {
    "urlPath" : "/url",
    "method" : "GET",
    "queryParameters" : {
      "number" : {
        "equalTo" : "321"
      },
      "name" : {
        "equalTo" : "TEST"
      }
    }
  },
  "response" : {
    "status" : 200
  }
}