Facing issue with WildcardMatcher and '?' #26

Closed
opened 2025-12-29 14:21:16 +01:00 by adam · 5 comments
Owner

Originally created by @pradkhanna on GitHub (May 10, 2017).

Originally assigned to: @StefH on GitHub.

Hi
I'm building a mock response for the uri...
/config/api/foundation/economic-regions/search?channel=1&brand=2

though the mock is setup... I'm getting response for all characters except ? in the uri.
like,
/config/api/foundation/economic-regions/searchachannel=1&brand=2
/config/api/foundation/economic-regions/search.channel=1&brand=2

From the code here, I see the Regex Replace(@"?", ".")

How do I build the mock for my uri? Please Help.

Originally created by @pradkhanna on GitHub (May 10, 2017). Originally assigned to: @StefH on GitHub. Hi I'm building a mock response for the uri... /config/api/foundation/economic-regions/search?channel=1&brand=2 though the mock is setup... I'm getting response for all characters except ? in the uri. like, /config/api/foundation/economic-regions/searchachannel=1&brand=2 /config/api/foundation/economic-regions/search.channel=1&brand=2 From the code here, I see the Regex Replace(@"\?", ".") How do I build the mock for my uri? Please Help.
adam added the question label 2025-12-29 14:21:16 +01:00
adam closed this issue 2025-12-29 14:21:16 +01:00
Author
Owner

@StefH commented on GitHub (May 10, 2017):

I guess you want to match parameters?
Then you can use something like:

... Create().WithParam("bar", "1", "2");

which will match an url like : http://localhost/foo?bar=1&bar=2

@StefH commented on GitHub (May 10, 2017): I guess you want to match parameters? Then you can use something like: ```c# ... Create().WithParam("bar", "1", "2"); ``` which will match an url like : `http://localhost/foo?bar=1&bar=2`
Author
Owner

@pradkhanna commented on GitHub (May 11, 2017):

Thanks StefH.
But, I'm using a .json configured mapping something like this....

{
  "Request": {
    "Path": {
      "Matchers": [
        {
          "Name": "WildcardMatcher",
          "Pattern": "/config/api/foundation/economic-regions/search"
        }
      ]
    },
    "Methods": [
      "get"
    ]
  },
  "Response": {
    "BodyAsJson": _{"Response_Json": "Goes here"}_,
    "Headers": {
      "Content-Type": "application/json"
    }
  }
}

so your Create().WithParam("bar", "1", "2"); would be a RequestMessageParamMatcher? and at what level in the above config .json's "Request" would it go?

@pradkhanna commented on GitHub (May 11, 2017): Thanks StefH. But, I'm using a .json configured mapping something like this.... ```js { "Request": { "Path": { "Matchers": [ { "Name": "WildcardMatcher", "Pattern": "/config/api/foundation/economic-regions/search" } ] }, "Methods": [ "get" ] }, "Response": { "BodyAsJson": _{"Response_Json": "Goes here"}_, "Headers": { "Content-Type": "application/json" } } } ``` so your **Create().WithParam("bar", "1", "2");** would be a **RequestMessageParamMatcher?** and at what level in the above config .json's "Request" would it go?
Author
Owner

@StefH commented on GitHub (May 11, 2017):

Maybe a better option would be to use the RegexMatcher to create a regular expression which matches your url

@StefH commented on GitHub (May 11, 2017): Maybe a better option would be to use the RegexMatcher to create a regular expression which matches your url
Author
Owner

@pradkhanna commented on GitHub (May 20, 2017):

Sorry for the late response. I've got the response mapped using .withParam(); and got my mapping.json file configured using it. Thanks again.

@pradkhanna commented on GitHub (May 20, 2017): Sorry for the late response. I've got the response mapped using .withParam(); and got my mapping.json file configured using it. Thanks again.
Author
Owner

@StefH commented on GitHub (May 20, 2017):

Cool !

@StefH commented on GitHub (May 20, 2017): Cool !
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/WireMock.Net-wiremock#26