Open luke-pp opened 3 weeks ago
Hi @luke-pp
It sounds reasonable, don't know if it's easy to implement @fabricereix but the features seems "natural" and user can expect it to work.
Hello, Yes, we could treat the Hurl Object as a JSON Object implicitly and apply jsonpath on it. We will have to convert each of its value to a JSON entity. We could also make it fail if the conversion does not make sense.
Just changed it from "bug" to "enhancement"
In my company's GraphQL APIs, we can get back some deeply nested json responses with a lot of data, and often we want to perform many different assertions against various parts of the response - ideally we'd like to organize these assertions by capturing one part of the response, and then performing assertions on each captured subsection separately. Here's a simplified example using the star wars API to show what I mean:
HTTP 200 [Captures] bespin: jsonpath "$.data.allPlanets.edges[?(@.node.name == 'Bespin')]" nth 0 tatooine: jsonpath "$.data.allPlanets.edges[0]"
[Asserts] variable "bespin" jsonpath "$.node.diameter" == 118000 variable "bespin" jsonpath "$.node.population" == 6000000
variable "tatooine" jsonpath "$.node.diameter" == 10465 variable "tatooine" jsonpath "$.node.population" == 200000
jsonpath "$.data.allPlanets.edges[?(@.node.name == 'Bespin')].node.diamter" nth 0 == 118000
match value { Value::String(text) => { let json = match serde_json::fromstr(text) { Err() => { return Err(RunnerError::new( source_info, RunnerErrorKind::QueryInvalidJson, false, )); } Ok(v) => v, }; eval_jsonpath_json(&json, expr, variables) } Value::Object => { eval_jsonpath_json(&value, expr, variables) } v => { let kind = RunnerErrorKind::FilterInvalidInput(v._type()); Err(RunnerError::new(source_info, kind, assert)) } }