rust_json_schema 0.3.0 → 0.4.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/Cargo.lock +558 -282
- data/README.md +1 -1
- data/ext/rust_json_schema/Cargo.toml +1 -1
- data/ext/rust_json_schema/src/lib.rs +9 -14
- data/lib/rust_json_schema/version.rb +1 -1
- metadata +3 -6
data/README.md
CHANGED
@@ -5,7 +5,7 @@
|
|
5
5
|
`rust_json_schema` is a Ruby wrapper gem for Rust's [jsonschema-rs crate](https://github.com/Stranger6667/jsonschema-rs).
|
6
6
|
|
7
7
|
> [!IMPORTANT]
|
8
|
-
> This gem is built with `json_schema` crate version `0.
|
8
|
+
> This gem is built with `json_schema` crate version `0.29.1`, and therefore does not support any features for any potential future versions of the crate. I will review and accept PRs if you would like to work on adding support for newer versions of the crate. I generally am trying to keep things up to date but I am not cutting new releases for each new patch version of the crate.
|
9
9
|
|
10
10
|
The minimum Ruby version required by this gem is 3.0, due to the runtime Rust libraries that make the extensions possible (and easy).
|
11
11
|
|
@@ -1,6 +1,6 @@
|
|
1
1
|
extern crate serde_json;
|
2
2
|
|
3
|
-
use jsonschema::
|
3
|
+
use jsonschema::Draft;
|
4
4
|
use magnus::{
|
5
5
|
exception::ExceptionClass,
|
6
6
|
function,
|
@@ -14,7 +14,7 @@ use magnus::{
|
|
14
14
|
|
15
15
|
#[wrap(class = "RustJSONSchema::Validator")]
|
16
16
|
struct Validator {
|
17
|
-
schema:
|
17
|
+
schema: jsonschema::Validator,
|
18
18
|
draft: Draft,
|
19
19
|
}
|
20
20
|
|
@@ -52,10 +52,7 @@ impl Validator {
|
|
52
52
|
}
|
53
53
|
};
|
54
54
|
|
55
|
-
let
|
56
|
-
schema.with_draft(draft);
|
57
|
-
|
58
|
-
let schema = match schema.compile(&value) {
|
55
|
+
let schema = match jsonschema::options().with_draft(draft).build(&value) {
|
59
56
|
Ok(schema) => schema,
|
60
57
|
Err(error) => {
|
61
58
|
return Err(Error::new(
|
@@ -108,15 +105,13 @@ impl Validator {
|
|
108
105
|
|
109
106
|
let mut errors: Vec<String> = vec![];
|
110
107
|
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
};
|
108
|
+
for error in self.schema.iter_errors(&value) {
|
109
|
+
let path = match format!("{}", error.instance_path).as_str() {
|
110
|
+
"" => "/".to_string(),
|
111
|
+
p => p.to_string(),
|
112
|
+
};
|
117
113
|
|
118
|
-
|
119
|
-
}
|
114
|
+
errors.push(format!("path \"{}\": {}", path, error));
|
120
115
|
}
|
121
116
|
|
122
117
|
Ok(errors)
|
metadata
CHANGED
@@ -1,14 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rust_json_schema
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.4.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Taylor Thurlow
|
8
|
-
autorequire:
|
9
8
|
bindir: exe
|
10
9
|
cert_chain: []
|
11
|
-
date:
|
10
|
+
date: 1980-01-02 00:00:00.000000000 Z
|
12
11
|
dependencies:
|
13
12
|
- !ruby/object:Gem::Dependency
|
14
13
|
name: rake-compiler
|
@@ -66,7 +65,6 @@ metadata:
|
|
66
65
|
homepage_uri: https://github.com/taylorthurlow/rust_json_schema-rb
|
67
66
|
source_code_uri: https://github.com/taylorthurlow/rust_json_schema-rb
|
68
67
|
changelog_uri: https://github.com/taylorthurlow/rust_json_schema-rb/releases
|
69
|
-
post_install_message:
|
70
68
|
rdoc_options: []
|
71
69
|
require_paths:
|
72
70
|
- lib
|
@@ -81,8 +79,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
81
79
|
- !ruby/object:Gem::Version
|
82
80
|
version: 3.3.11
|
83
81
|
requirements: []
|
84
|
-
rubygems_version: 3.
|
85
|
-
signing_key:
|
82
|
+
rubygems_version: 3.6.8
|
86
83
|
specification_version: 4
|
87
84
|
summary: Ruby wrapper for jsonschema-rs
|
88
85
|
test_files: []
|