you should be able to achieve with the property ma...
# help
d
you should be able to achieve with the property matching described in: https://github.com/wiremock/wiremock-state-extension#full-flexible-property-match
j
Ok perfect, thanks for the quick response. Its definitely able to understand the handlebars notation in the parameter matcher. It must be something I'm incorrectly setting up. I'll double check my setup. Thank you.
d
in case it doesn't work, would be great if you can push a repo somewhere so that I can check it
j
Yeah, I'll give it another shot to update what I have, I wanted to double check. I can publish a public repo if it still doesn't work. Thanks you.
👍 1
Just to close this off, I created a sample project and everything worked perfectly. I went back and checked my original version and I had something like
"urlPathPattern": "/api/v1/resource/[^\\/]+",
the id I was trying to access was at the regex part of the uri path but I had
"contains": "{{request.pathSegments.[1]}}"
which was returning the
api
once I updated it to
"{{request.pathSegments.[3]}}"
everything worked exactly as expected. I had one last question, I'm trying to mock off an external system where the body of the request is text. The text contains an ID that I have stored in state from a previous request, is there any matcher that can be used in
state-matcher
that would look at the entire request body and if it contained the id in state then it would successfully match. Something like:
Copy code
"customMatcher": {
  "name": "state-matcher",
  "parameters": {
    "hasContext": "id-to-request-body-matcher",
    "property": {
      "idToFind": {
        "contains": "{{request.body}}"
      }
    }
  }
}
Ideally if it worked something like bodyPatterns that would be great:
Copy code
"request" : {
  "url" : "/api/example/endpoint",
  "method" : "POST",
  "bodyPatterns": [
    {
      "contains": "{{state context='id-to-request-body-matcher' property='idToFind' default=''}}"
    }
  ]
},
but for the
state-matcher
. I'm not sure the handlebars notation for accessing state is handled inside the
request
above.
d
Handlebar helpers are registered globally, so you should be able to use it wherever you can put handlebar notations. It should fit in like any other handlebar command. I’m curious about your results.