You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
JsonPathMatcher does not allow the usage of filters with non array JSON.
In the example provided in the wiki, the first matching example listed { "things": { "name": "RequiredThing" } } does not actually request match with the body matcher pattern "$.things[?(@.name == 'RequiredThing')]".
Expected behavior:
JsonPathMatcher filters should work with non array JSON
Test to reproduce
Set body matcher pattern to "$.things[?(@.name == 'RequiredThing')]"
Send request with JSON body { "things": { "name": "RequiredThing" } }
Expected behavior: Returns request match
Actual behavior: Does not match
The other example in the wiki { "things": [ { "name": "RequiredThing" }, { "name": "Wiremock" } ] } works correctly because { "name": "RequiredThing" } is in an array.
I believe outside of wiremock, JSONPath filters are actually only supposed to be used with arrays, so this may not actually be a bug. If so, the wiki should be updated. However, I believe there is still value in allowing the ability to use filters for non-array JSON matches, otherwise there does not seem to be a way to request match multiple JSON properties without doing an exact match of all properties using JsonMatcher. (I believe JsonPartialMatcher only allows you to match 1 property, but let me know if I'm wrong about this).
The text was updated successfully, but these errors were encountered:
Describe the bug
JsonPathMatcher
does not allow the usage of filters with non array JSON.In the example provided in the wiki, the first matching example listed
{ "things": { "name": "RequiredThing" } }
does not actually request match with the body matcher pattern"$.things[?(@.name == 'RequiredThing')]"
.Expected behavior:
JsonPathMatcher
filters should work with non array JSONTest to reproduce
"$.things[?(@.name == 'RequiredThing')]"
{ "things": { "name": "RequiredThing" } }
Expected behavior: Returns request match
Actual behavior: Does not match
Other related info
{ "things": [ { "name": "RequiredThing" }, { "name": "Wiremock" } ] }
works correctly because{ "name": "RequiredThing" }
is in an array.JsonMatcher
. (I believeJsonPartialMatcher
only allows you to match 1 property, but let me know if I'm wrong about this).The text was updated successfully, but these errors were encountered: