From 57b73b0f115580fab89ab41dc1ac85c92f368b0c Mon Sep 17 00:00:00 2001 From: Dmitry Dygalo Date: Fri, 20 Sep 2024 09:58:17 +0200 Subject: [PATCH] chore: Update jsonschema to 0.20.0 Signed-off-by: Dmitry Dygalo --- Cargo.lock | 4 ++-- schemars/Cargo.toml | 2 +- schemars/tests/integration/test_helper.rs | 28 +++++++++++------------ 3 files changed, 17 insertions(+), 17 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 0f076208..a6bdd873 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -416,9 +416,9 @@ dependencies = [ [[package]] name = "jsonschema" -version = "0.19.0" +version = "0.20.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2be7aa9f08a262039c0b5eb11b792e4353dad5263f78e33312b7ba9e43b32ae9" +checksum = "f2eef4e82b548e08ac880d307c8e8838b45f497a08d3202f3b26c9debaed8058" dependencies = [ "ahash", "anyhow", diff --git a/schemars/Cargo.toml b/schemars/Cargo.toml index 384f3eae..af913a8d 100644 --- a/schemars/Cargo.toml +++ b/schemars/Cargo.toml @@ -37,7 +37,7 @@ uuid1 = { version = "1.0", default-features = false, optional = true, package = pretty_assertions = "1.2.1" trybuild = "1.0" serde = { version = "1.0", features = ["derive"] } -jsonschema = { version = "0.19.0", default-features = false } +jsonschema = { version = "0.20", default-features = false } snapbox = { version = "0.6.17", features = ["json"] } serde_repr = "0.1.19" # Use github source until published garde version supports `length(equal = ...)` attr diff --git a/schemars/tests/integration/test_helper.rs b/schemars/tests/integration/test_helper.rs index 1d99b230..64a3394b 100644 --- a/schemars/tests/integration/test_helper.rs +++ b/schemars/tests/integration/test_helper.rs @@ -1,4 +1,4 @@ -use jsonschema::JSONSchema as CompiledSchema; +use jsonschema::Validator; use schemars::{ generate::{Contract, SchemaSettings}, JsonSchema, Schema, @@ -17,8 +17,8 @@ pub struct TestHelper { phantom: PhantomData, de_schema: Schema, ser_schema: Schema, - de_schema_compiled: OnceCell, - ser_schema_compiled: OnceCell, + de_schema_validator: OnceCell, + ser_schema_validator: OnceCell, validator: fn(&T) -> bool, } @@ -33,8 +33,8 @@ impl TestHelper { phantom: PhantomData, de_schema, ser_schema, - de_schema_compiled: OnceCell::new(), - ser_schema_compiled: OnceCell::new(), + de_schema_validator: OnceCell::new(), + ser_schema_validator: OnceCell::new(), validator: |_| true, } } @@ -52,8 +52,8 @@ impl TestHelper { phantom: PhantomData, de_schema, ser_schema, - de_schema_compiled: OnceCell::new(), - ser_schema_compiled: OnceCell::new(), + de_schema_validator: OnceCell::new(), + ser_schema_validator: OnceCell::new(), validator: |_| true, } } @@ -137,22 +137,22 @@ impl TestHelper { } fn de_schema_validate(&self, instance: &Value) -> bool { - self.de_schema_compiled - .get_or_init(|| compile_schema(&self.de_schema)) + self.de_schema_validator + .get_or_init(|| build_validator(&self.de_schema)) .is_valid(instance) } fn ser_schema_validate(&self, instance: &Value) -> bool { - self.ser_schema_compiled - .get_or_init(|| compile_schema(&self.ser_schema)) + self.ser_schema_validator + .get_or_init(|| build_validator(&self.ser_schema)) .is_valid(instance) } } -fn compile_schema(schema: &Schema) -> CompiledSchema { - CompiledSchema::options() +fn build_validator(schema: &Schema) -> Validator { + jsonschema::options() .should_validate_formats(true) - .compile(schema.as_value()) + .build(schema.as_value()) .expect("valid schema") }