Help converting a slightly more complex Wiremock.org template
See original GitHub issueI’m experimenting using this instead of wiremock.org and am doing some POC stuff. I’ve hit a couple of problems with Body matching using XPath, and I could use some guidance on how to accomplish the response request->response items and dynamically created response parts. I have a template here (cnp.json config.zip ) and a partially converted one along with what to post. https://localhost:9443/vap/communicator/online
The current issue is that my XPath matching rules both have to fail for it to fail to match, but I need ANY rule to cause it to fail. As it stands, if I change one of the values in the post but not the second it still says it’s a match. Also, any help with building the response would be great.
cnp.json
{
"Title": "Authorization",
"Request": {
"Path": {
"Matchers": [
{
"Name": "WildcardMatcher",
"Pattern": "/vap/communicator/online"
}
]
},
"Methods": [
"post"
],
"Body": {
"Matchers": [
{
"Name": "XPathMatcher",
"Pattern": "//*[local-name() = 'amount']/text() = 100000"
},
{
"Name": "XPathMatcher",
"Pattern": "//*[local-name() = 'name']/text() = 'Jane John'"
}
]
}
},
"Response": {
"StatusCode": 200,
"Body": "<xml>ok</xml>",
"UseTransformer": false,
"Headers": {
"Content-Type": "application/xml"
}
}
}
Issue Analytics
- State:
- Created a year ago
- Comments:17 (6 by maintainers)
Top Results From Across the Web
Mock API Response Templating
This enables attributes of the request to be used in generating the response e.g. to pass the value of a request ID header...
Read more >Returning stubbed HTTP responses to specific requests
A core feature of WireMock is the ability to return canned HTTP responses for requests matching criteria. These are described in detail in...
Read more >WireMock API Templates Library
The library.wiremock.org site provides a catalog of API Templates that can be used with both WireMock or WireMock Cloud.
Read more >WireMock Overview and Basics
WireMock is a popular open-source tool for API mock testing with over 5 million downloads per month. It can help you to create...
Read more >Extending WireMock via custom code
Via WireMock's extension mechanism it is possible to dynamically modify responses, allowing header re-writing and templated responses amongst other things.
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

I will be testing it this weekend. Overwhelmed with a large release the past few days. Thanks a lot for looking into this.
Maybe a good use case to build this in .net Maui 😀