-
Notifications
You must be signed in to change notification settings - Fork 532
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
Assert against every member of a JSONPATH collection? #347
Comments
Your understanding of Hurl is good. In a testing/controlled environment, responses can be tested "statically" as you suggested.
I like your "each" operator for a list.
|
Very good idea, we could also support
A sidenote: in Hurl syntax, we have the notion of query and predicate. Ex:
query: If we negate:
(not if part of predicate) Using
@danielbprice Thanks for the idea; is your project using Hurl Open Source so we can look at it? I'm really interested to see how other people use Hurl! |
@jcamiel unfortunately it's not a piece of open source that I can share. It's an API gateway to support a single enterprise customer, mapping an older version of an API to a newer version in a situation where that was really the only option. Also "none" and "any" seem smart. Thanks for listening. |
Hi, I'm sorry if this is an ignorant question. Let's imagine an API which returns an array of elements:
My basic use case is that I want to assert that all of the values of "item" match the pattern "value.*". Today it seems like I can do:
jsonpath "$.data[0].item" matches "value.*"
However I would really like a way to say:
jsonpath "$.data[*].item" matches "value.*"
That is to say, test each member against the regex. What seems to happen when I try this is that all of the items are concatenated, so that the match is against something like
[string <value1>, string <value2>, string <value3>]
(according to the output of hurl). I can see using https://jsonpath.com/ that this is due to the way jsonpath processes the input.I tried to bend jsonpath to emit a collection of elements whose value does not match
value.*
(so I could assert that zero things remained) but couldn't figure it out.Something I wondered along the way is whether it would make sense to be able to run the predicate on each value in a resultant collection. So
jsonpath "$.data[*].item" EACH matches "value.*"
Thanks for your consideration! I have had good success using hurl to help me build an API gateway.
The text was updated successfully, but these errors were encountered: