Make jsonpath module private.

This commit is contained in:
jcamiel 2023-02-13 13:20:40 +01:00
parent 361fd8bd63
commit ee300eb265
No known key found for this signature in database
GPG Key ID: 07FF11CFD55356CC
4 changed files with 45 additions and 39 deletions

View File

@ -16,41 +16,44 @@
* *
*/ */
/* //! JSONPath specs.
* jsonpath specs //!
* There is no proper specifications for jsonpath. //! There is no proper specifications for JSONPath.
* The defacto one is still https://goessner.net/articles/JsonPath/ //! The de-facto one is still <https://goessner.net/articles/JsonPath/>
* Hurl will try to follow this one as closely as possible //! Hurl will try to follow this one as closely as possible
* //!
* There are a few edge cases for which several implementations differ //! There are a few edge cases for which several implementations differ
* The online app https://jsonpath.herokuapp.com/ might be used to test them //! The online app <https://jsonpath.herokuapp.com/> might be used to test them
* We describe below the behaviour that we expect in Hurl. //! We describe below the behaviour that we expect in Hurl.
* //!
* Specify a field key in a subscript operator: $['name'] //! Specify a field key in a subscript operator: `$['name']`
* The key must be enclosed within single quotes only. //! The key must be enclosed within single quotes only.
* The following expressions will not be valid: $["name"] and $[name] //! The following expressions will not be valid: `$["name"]` and `$[name]`
* //!
* Accessing a key containing a single quote must be escape: $['\''] //! Accessing a key containing a single quote must be escape: `$['\'']`
* Key with unicode are supported: $['✈'] //! Key with unicode are supported: `$['✈']`
* //!
* Any character within these quote won't have a specific meaning: //! 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 '*'. It is different from `$[*]` which selects all elements
* $['.'] selects the element with key '.'. //! - `$['.']` selects the element with key '.'.
* //!
* The dot notation is usually more readable the the bracket notation //! The dot notation is usually more readable the the bracket notation
* but it is more limited in terms of allowed characters //! but it is more limited in terms of allowed characters
* The following characters are allowed: //! The following characters are allowed:
* alphanumeric //! alphanumeric
* _ (underscore) //! _ (underscore)
* //!
* Filters can be applied to element of an array with the ?(@.key PREDICATE) notation. //! Filters can be applied to element of an array with the `?(@.key PREDICATE)` notation.
* The key can can specify one or more levels. //! The key can can specify one or more levels.
* For example, `.price.US` specify field 'US' in an object for the field price. //! For example, `.price.US` specify field 'US' in an object for the field price.
* The predicate if not present just checks the key existence. //! The predicate if not present just checks the key existence.
*/ //!
pub use self::parser::parse; pub use self::parser::parse;
mod ast; mod ast;
mod eval; mod eval;
mod parser; mod parser;
#[cfg(test)]
mod tests;

View File

@ -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 serde_json::json;
use std::fs::read_to_string; use std::fs::read_to_string;
@ -154,7 +158,7 @@ fn book3_value() -> serde_json::Value {
fn test_bookstore_path() { fn test_bookstore_path() {
// examples from https://goessner.net/articles/JsonPath/ // 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(); let expr = jsonpath::parse("$.store.book[*].author").unwrap();
assert_eq!( assert_eq!(
expr.eval(bookstore_value()), expr.eval(bookstore_value()),

View File

@ -20,8 +20,8 @@
pub mod cli; pub mod cli;
mod html; mod html;
pub mod http; pub mod http;
pub mod json; mod json;
pub mod jsonpath; mod jsonpath;
pub mod output; pub mod output;
pub mod report; pub mod report;
pub mod runner; pub mod runner;

View File

@ -17,10 +17,9 @@
*/ */
use std::fmt; 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)] #[derive(Clone, Debug)]
pub enum Value { pub enum Value {
Bool(bool), Bool(bool),