-
-
Notifications
You must be signed in to change notification settings - Fork 480
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
eachKeyLike
does not allow type matchers, only value matches and works unexpectedly with regexes.
#1813
Comments
The problem is that I'm going to deprecate those methods, and add ones that actually act on the keys. |
I've added two new methods, so you can do something like newJsonBody(body ->
body.object("a", aObj -> {
aObj.eachKeyMatching(Matchers.regexp("prop\\d+", "prop1"));
aObj.eachValueMatching("prop1", propObj -> propObj.stringType("value", "x"));
})) I think this is what you want. |
Hey @nlandjev, are you able to test with the current version and confirm? |
Hi, Thanks for the quick fix. |
I'll release it soon (some time this week). I have one more change I want to get into the release first. |
4.6.12 is released |
Thank you, I will check it out next week and close the issue. |
We've tested this and it works as expected. I'm closing the issue. Thanks for implementing :) |
We are using Pact to verify a JSON response payload that satisfies the following properties:
For example this object is valid (provided prop1 and prop2 match the regular expression):
We use the following code to generate the Pact JSON file (snippet just for the object):
This generates the following Pact file (snippet just for the object):
This leads to a problem on the producer side that the body in the example above get accepted even if prop1 and prop2 don't match the regular expression. If we change the matchers in line 7 and 10 in the Pact JSON above to "match": "type", then the body gets rejected as expected. Is there a way to specify this with eachKeyLike? Or is there another way to specify a regex for the keys to match?
Regards, Nikolay
Relevant versions from the pom file:
au.com.dius.pact.consumer:junit5 -> 4.6.6
au.com.dius.pact.provider:junit5spring -> 4.6.6
The text was updated successfully, but these errors were encountered: