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.
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.19.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.
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
 
@@ -10,7 +10,7 @@ publish = false
10
10
  crate-type = ["cdylib"]
11
11
 
12
12
  [dependencies]
13
- jsonschema = "0.19"
13
+ jsonschema = "0.29.1"
14
14
  magnus = "0.7"
15
15
  serde_json = "1.0"
16
16
  rb-sys = { version = "*", default-features = false, features = ["ruby-static"] }
@@ -1,6 +1,6 @@
1
1
  extern crate serde_json;
2
2
 
3
- use jsonschema::{Draft, 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: JSONSchema,
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 mut schema = JSONSchema::options();
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
- if let Err(validation_errors) = self.schema.validate(&value) {
112
- for error in validation_errors {
113
- let path = match format!("{}", error.instance_path).as_str() {
114
- "" => "/".to_string(),
115
- p => p.to_string(),
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
- errors.push(format!("path \"{}\": {}", path, error));
119
- }
114
+ errors.push(format!("path \"{}\": {}", path, error));
120
115
  }
121
116
 
122
117
  Ok(errors)
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module RustJSONSchema
4
- VERSION = "0.3.0"
4
+ VERSION = "0.4.1"
5
5
  end
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.3.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: 2024-09-16 00:00:00.000000000 Z
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.5.18
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: []