diff --git a/packages/hurl/src/jsonpath/mod.rs b/packages/hurl/src/jsonpath/mod.rs index 2838d9660..ba62fffd5 100644 --- a/packages/hurl/src/jsonpath/mod.rs +++ b/packages/hurl/src/jsonpath/mod.rs @@ -16,41 +16,44 @@ * */ -/* - * jsonpath specs - * There is no proper specifications for jsonpath. - * The defacto one is still https://goessner.net/articles/JsonPath/ - * Hurl will try to follow this one as closely as possible - * - * There are a few edge cases for which several implementations differ - * The online app https://jsonpath.herokuapp.com/ might be used to test them - * We describe below the behaviour that we expect in Hurl. - * - * Specify a field key in a subscript operator: $['name'] - * The key must be enclosed within single quotes only. - * The following expressions will not be valid: $["name"] and $[name] - * - * Accessing a key containing a single quote must be escape: $['\''] - * Key with unicode are supported: $['✈'] - * - * Any character within these quote won't have a specific meaning: - * $['*'] selects the element with key '*'. It is different from $[*] which selects all elements - * $['.'] selects the element with key '.'. - * - * The dot notation is usually more readable the the bracket notation - * but it is more limited in terms of allowed characters - * The following characters are allowed: - * alphanumeric - * _ (underscore) - * - * Filters can be applied to element of an array with the ?(@.key PREDICATE) notation. - * The key can can specify one or more levels. - * For example, `.price.US` specify field 'US' in an object for the field price. - * The predicate if not present just checks the key existence. - */ +//! JSONPath specs. +//! +//! There is no proper specifications for JSONPath. +//! The de-facto one is still +//! Hurl will try to follow this one as closely as possible +//! +//! There are a few edge cases for which several implementations differ +//! The online app might be used to test them +//! We describe below the behaviour that we expect in Hurl. +//! +//! Specify a field key in a subscript operator: `$['name']` +//! The key must be enclosed within single quotes only. +//! The following expressions will not be valid: `$["name"]` and `$[name]` +//! +//! Accessing a key containing a single quote must be escape: `$['\'']` +//! Key with unicode are supported: `$['✈']` +//! +//! Any character within these quote won't have a specific meaning: +//! - `$['*']` selects the element with key '*'. It is different from `$[*]` which selects all elements +//! - `$['.']` selects the element with key '.'. +//! +//! The dot notation is usually more readable the the bracket notation +//! but it is more limited in terms of allowed characters +//! The following characters are allowed: +//! alphanumeric +//! _ (underscore) +//! +//! Filters can be applied to element of an array with the `?(@.key PREDICATE)` notation. +//! The key can can specify one or more levels. +//! For example, `.price.US` specify field 'US' in an object for the field price. +//! The predicate if not present just checks the key existence. +//! pub use self::parser::parse; mod ast; mod eval; mod parser; + +#[cfg(test)] +mod tests; diff --git a/packages/hurl/tests/jsonpath.rs b/packages/hurl/src/jsonpath/tests/mod.rs similarity index 97% rename from packages/hurl/tests/jsonpath.rs rename to packages/hurl/src/jsonpath/tests/mod.rs index 953335485..4f881a06f 100644 --- a/packages/hurl/tests/jsonpath.rs +++ b/packages/hurl/src/jsonpath/tests/mod.rs @@ -16,7 +16,11 @@ * */ -use hurl::jsonpath; +//! Integration tests for jsonpath module. +//! These tests are not located at the root of the project, like Rust integration tests +//! are usually located since we do not want to expose the jsonpath module to our public API. + +use crate::jsonpath; use serde_json::json; use std::fs::read_to_string; @@ -154,7 +158,7 @@ fn book3_value() -> serde_json::Value { fn test_bookstore_path() { // examples from https://goessner.net/articles/JsonPath/ - //the authors of all books in the store + // the authors of all books in the store let expr = jsonpath::parse("$.store.book[*].author").unwrap(); assert_eq!( expr.eval(bookstore_value()), diff --git a/packages/hurl/src/lib.rs b/packages/hurl/src/lib.rs index 729b698db..287754a08 100644 --- a/packages/hurl/src/lib.rs +++ b/packages/hurl/src/lib.rs @@ -20,8 +20,8 @@ pub mod cli; mod html; pub mod http; -pub mod json; -pub mod jsonpath; +mod json; +mod jsonpath; pub mod output; pub mod report; pub mod runner; diff --git a/packages/hurl/src/runner/value.rs b/packages/hurl/src/runner/value.rs index 6418d56cf..727fba87e 100644 --- a/packages/hurl/src/runner/value.rs +++ b/packages/hurl/src/runner/value.rs @@ -17,10 +17,9 @@ */ use std::fmt; +/// System types used in Hurl. /// -/// Type system used in hurl -/// Values are used by queries, captures, asserts and predicates -/// +/// Values are used by queries, captures, asserts and predicates. #[derive(Clone, Debug)] pub enum Value { Bool(bool),