Comments (5)
Could you give me some more detail as to why you need this?
I've got some ideas about how to improve body specifications that may help you if implemented, so I'd be interested to know what pain points you're hitting.
Thanks,
Tom
from wiremock.
Hi,
I think that is very usefull have a posibility to configure the bodyPatterns in a external file when you have a large body in XML.
For example if i have a mapping like this:
{
"request": {
"method": "POST",
"url": "/product",
"bodyPatterns": [
{ "matches": "<product><name>Ball</name><manufacturer>A</manufacturer><price>.*</price><vendors_assigned><vendor>1</vendor><vendor>2</vendor><vendor>3</vendor></vendors_assigned></product>" }
]
},
"response": {
"status": 200,
"bodyFileName": "path/to/ballResponse.xml"
}
}
I think that is better to configure a mapping in this way:
{
"request": {
"method": "POST",
"url": "/product",
"bodyPatterns": [
{ "matchesFileName": "path/to/ballRequest.xml" }
]
},
"response": {
"status": 200,
"bodyFileName": "path/to/ballResponse.xml"
}
}
where the ballRequest.xml have the content of the first mapping.
Thanks and greetings,
Martin.
from wiremock.
OK...I have mixed feelings about this idea.
My personal view is that it's desirable not to make your stub specs any more specific than necessary as this tends to make your tests brittle.
However, I realise that regexes are a bit of a blunt instrument in this context, so I've been thinking for a while about adding support for body matching on JSONPath and XPath.
Something like:
{
"request": {
"method": "POST",
"url": "/product",
"bodyPatterns": [
{ "matchesXPath": "/product[name='ball']" },
{ "matchesXPath": "/product[manufacturer='A']" }
]
},
"response": {
"status": 200,
"bodyFileName": "path/to/ballResponse.xml"
}
}
Do you think this would help?
from wiremock.
Hi,
I think that would be great !!
It is very helpful to have the option of XPath matching.
Thanks,
Martín.
from wiremock.
OK, I'll bump that up the to-do list in that case. Thanks for the feedback.
from wiremock.
Related Issues (20)
- Adding more jettyAcceptors seems to do nothing besides cause thread contention. HOT 1
- align new join handlebar helper with features present in the join provided in the library, but not covered yet
- Expose args in Options so extensions can read it
- Possible memory leak ? HOT 15
- Prevent creating multiple stub mappings with the same ID HOT 1
- Support virtual threads in Jetty server for standalone deploy
- Error when proxying to a host that is only accessible via IPv6 HOT 1
- Formatted dates not in UTC
- __files created by default since v3.6.0 HOT 1
- absent operand must be a non-null string
- Array and data manipulation in handlebars template when using docker
- FileItemPartAdapter returning multipart's field name instead of a filename
- Avoiding reading zipfile entries repeatedly in ClasspathFileSource
- Support disabled state for stub mappings HOT 1
- Add a unique id to the template request model
- Add self-description callback(s) to MatchResult for use in Diff
- Report webhook errors and results as sub-events
- Support mTLS (client certificate) for standalone WireMock client
- urlPathTemplate does not work in combination with queryParameters HOT 1
- Allow loading a stub for a single file instead of a directory
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from wiremock.