Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Facing issue with WildcardMatcher and '?' #28

Closed
pradkhanna opened this issue May 10, 2017 · 5 comments
Closed

Facing issue with WildcardMatcher and '?' #28

pradkhanna opened this issue May 10, 2017 · 5 comments
Assignees
Labels

Comments

@pradkhanna
Copy link

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.

@StefH StefH self-assigned this May 10, 2017
@StefH StefH added the question label May 10, 2017
@StefH
Copy link
Collaborator

StefH commented 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

@pradkhanna
Copy link
Author

pradkhanna commented 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?

@StefH
Copy link
Collaborator

StefH commented May 11, 2017

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

@pradkhanna
Copy link
Author

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

@StefH
Copy link
Collaborator

StefH commented May 20, 2017

Cool !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants