Skip to content

Commit 4442770

Browse files
authored
Update jsonschema dependency (#3286)
1 parent ff6f56d commit 4442770

File tree

4 files changed

+12
-12
lines changed

4 files changed

+12
-12
lines changed

crates/samples/components/json_validator/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ publish = false
88
crate-type = ["cdylib"]
99

1010
[dependencies]
11-
jsonschema = { version = "0.19", default-features = false }
11+
jsonschema = { version = "0.20", default-features = false }
1212
serde_json = {version = "1.0", default-features = false }
1313

1414
[dependencies.windows]

crates/samples/components/json_validator/src/lib.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use jsonschema::JSONSchema;
1+
use jsonschema::Validator;
22
use windows::{core::*, Win32::Foundation::*, Win32::System::Com::*};
33

44
// Creates a JSON validator object with the given schema. The returned handle must be freed
@@ -35,16 +35,16 @@ unsafe extern "system" fn ValidateJson(
3535
#[no_mangle]
3636
unsafe extern "system" fn CloseJsonValidator(handle: usize) {
3737
if handle != 0 {
38-
_ = Box::from_raw(handle as *mut JSONSchema);
38+
_ = Box::from_raw(handle as *mut Validator);
3939
}
4040
}
4141

4242
// Implementation of the `CreateJsonValidator` function so we can use `Result` for simplicity.
4343
unsafe fn create_validator(schema: *const u8, schema_len: usize, handle: *mut usize) -> Result<()> {
4444
let schema = json_from_raw_parts(schema, schema_len)?;
4545

46-
let compiled = JSONSchema::compile(&schema)
47-
.map_err(|error| Error::new(E_INVALIDARG, error.to_string()))?;
46+
let compiled =
47+
Validator::new(&schema).map_err(|error| Error::new(E_INVALIDARG, error.to_string()))?;
4848

4949
if handle.is_null() {
5050
return Err(E_POINTER.into());
@@ -70,9 +70,9 @@ unsafe fn validate(
7070

7171
let value = json_from_raw_parts(value, value_len)?;
7272

73-
// This looks a bit tricky but we're just turning the opaque handle into `JSONSchema` pointer
73+
// This looks a bit tricky but we're just turning the opaque handle into `Validator` pointer
7474
// and then returning a reference to avoid taking ownership of it.
75-
let schema = &*(handle as *const JSONSchema);
75+
let schema = &*(handle as *const Validator);
7676

7777
if schema.is_valid(&value) {
7878
if !sanitized_value.is_null() && !sanitized_value_len.is_null() {

crates/samples/components/json_validator_winrt/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ name = "sample"
99
crate-type = ["cdylib"]
1010

1111
[dependencies]
12-
jsonschema = { version = "0.19", default-features = false }
12+
jsonschema = { version = "0.20", default-features = false }
1313
serde_json = {version = "1.0", default-features = false }
1414

1515
[dependencies.windows]

crates/samples/components/json_validator_winrt/src/lib.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
mod bindings;
2-
use jsonschema::JSONSchema;
2+
use jsonschema::Validator;
33
use windows::{core::*, Win32::Foundation::*, Win32::System::WinRT::*};
44

55
// The `JsonValidator` struct represents the implementation of the `JsonValidator` class.
66
// The `implement` attribute provides the boilerplate COM and WinRT implementation support.
77
#[implement(bindings::JsonValidator)]
88
struct JsonValidator {
9-
schema: JSONSchema,
9+
schema: Validator,
1010
}
1111

1212
// Implement the `IJsonValidator` interface.
@@ -49,8 +49,8 @@ impl bindings::IJsonValidatorFactory_Impl for JsonValidatorFactory_Impl {
4949
fn CreateInstance(&self, schema: &HSTRING) -> Result<bindings::JsonValidator> {
5050
let schema = json_from_hstring(schema)?;
5151

52-
let schema = JSONSchema::compile(&schema)
53-
.map_err(|error| Error::new(E_INVALIDARG, error.to_string()))?;
52+
let schema =
53+
Validator::new(&schema).map_err(|error| Error::new(E_INVALIDARG, error.to_string()))?;
5454

5555
Ok(JsonValidator { schema }.into())
5656
}

0 commit comments

Comments
 (0)