jsonschema_rs 0.42.0 → 0.42.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 612136d54e48cbe70a384939de4ee760c240ebf37ffbb40924d8eb1bccf4e382
4
- data.tar.gz: a3b9968753b319ef31129311c9598be508dc331eca081386eb8de8f645a40cf1
3
+ metadata.gz: f7f354d248faf1bee6e0165b05f80dbff15b3a3edc1d3ccc037d7cea59c798c4
4
+ data.tar.gz: 4ee7a0389b58e6d71fe410bfce9e52e881fb1a805cbf0c93aa24c400748a56e2
5
5
  SHA512:
6
- metadata.gz: 93e07f2476489fcef0315b06b187895449435b072a269ce9cf29f302a481ba5a6e5ac4cf6bd75f79002f3aa5409d28283e76e6739bb7ce7578db7b2dd002e1dd
7
- data.tar.gz: 032c5b841a42b9e3ee5e4a3a4c03826074cabfcc4d24d3b9d71c3e85eed7b0c417c352e7b95f5d0e6a9ac87c888df0520961f45298095c17df26117f0b6cbd5c
6
+ metadata.gz: '097f632cf1db882708a7b8e2e45e7e4659c52f3de17147e0680cd24f2ef86aaa34624a8a9edd665b3029e1cf94983bd8053421797fb3d4ea1a1bc78d5f1050a3'
7
+ data.tar.gz: a51f9f9969c44d8119960caac5e018bf91b0ecd9372122d53e24881f1b9a08139401b28db07f024e48afafa45a080b83c77406bb7d58190df9d42f72283abaaf
data/CHANGELOG.md CHANGED
@@ -2,7 +2,16 @@
2
2
 
3
3
  ## [Unreleased]
4
4
 
5
+ ## [0.42.1] - 2026-02-17
6
+
7
+ ### Performance
8
+
9
+ - Reduce dynamic dispatch overhead for non-recursive `$ref` resolution.
10
+ - Cache ECMA regex transformations during `format: "regex"` validation.
11
+
5
12
  ## 0.42.0 - 2026-02-15
6
13
 
7
14
  - Initial public release
8
15
 
16
+ [Unreleased]: https://github.com/Stranger6667/jsonschema/compare/ruby-v0.42.1...HEAD
17
+ [0.42.1]: https://github.com/Stranger6667/jsonschema/compare/ruby-v0.42.0...ruby-v0.42.1
data/Cargo.toml CHANGED
@@ -1,6 +1,6 @@
1
1
  [package]
2
2
  name = "jsonschema-rb"
3
- version = "0.42.0"
3
+ version = "0.42.1"
4
4
  edition = "2021"
5
5
  authors = ["Dmitry Dygalo <dmitry@dygalo.dev>"]
6
6
  license = "MIT"
@@ -13,7 +13,7 @@ publish = false
13
13
  crate-type = ["cdylib"]
14
14
 
15
15
  [dependencies]
16
- jsonschema = { version = "0.42.0", default-features = false, features = ["arbitrary-precision", "resolve-http", "resolve-file", "tls-ring"] }
16
+ jsonschema = { version = "0.42.1", default-features = false, features = ["arbitrary-precision", "resolve-http", "resolve-file", "tls-ring"] }
17
17
  magnus = { version = "0.8", features = ["rb-sys"] }
18
18
  rb-sys = "0.9"
19
19
  serde = { workspace = true }
data/README.md CHANGED
@@ -36,8 +36,8 @@ validator.valid?(instance) # => true
36
36
 
37
37
  # Structured output (JSON Schema Output v1)
38
38
  evaluation = validator.evaluate(instance)
39
- evaluation.annotations.each do |ann|
40
- puts "Annotation at #{ann[:schemaLocation]}: #{ann[:annotations]}"
39
+ evaluation.errors.each do |err|
40
+ puts "Error at #{err[:instanceLocation]}: #{err[:error]}"
41
41
  end
42
42
  ```
43
43
 
@@ -86,7 +86,7 @@ If no pre-built gem is available for your platform, it will be compiled from sou
86
86
  ### Reusable validators
87
87
 
88
88
  For validating multiple instances against the same schema, create a reusable validator.
89
- `validator_for` automatically detects the draft version from the `$schema` keyword in the schema:
89
+ `validator_for` automatically detects the draft version from the `$schema` keyword in the schema and falls back to Draft 2020-12:
90
90
 
91
91
  ```ruby
92
92
  validator = JSONSchema.validator_for({
@@ -149,7 +149,7 @@ Each custom keyword class must implement:
149
149
 
150
150
  ### Structured evaluation output
151
151
 
152
- When you need more than a boolean result, use the `evaluate` API to access the JSON Schema Output v1 formats:
152
+ When you need more than a boolean result, use the `evaluate` API to access the [JSON Schema Output v1](https://json-schema.org/draft/2020-12/json-schema-core#name-output-formatting) formats:
153
153
 
154
154
  ```ruby
155
155
  schema = {
@@ -165,34 +165,79 @@ validator = JSONSchema.validator_for(schema)
165
165
  evaluation = validator.evaluate({ "age" => "not_an_integer" })
166
166
 
167
167
  evaluation.valid? # => false
168
+ ```
169
+
170
+ **Flag output** — simplest, just valid/invalid:
168
171
 
169
- # Flag output (simplest)
172
+ ```ruby
170
173
  evaluation.flag
171
- # => { "valid" => false }
174
+ # => {valid: false}
175
+ ```
176
+
177
+ **List output** — flat list of all evaluation nodes:
172
178
 
173
- # List output (flat)
179
+ ```ruby
174
180
  evaluation.list
175
- # => { "valid" => false, "details" => [
176
- # { "valid" => false, "evaluationPath" => "", "instanceLocation" => "", "schemaLocation" => "" },
177
- # { "valid" => false, "evaluationPath" => "/required", "instanceLocation" => "", "schemaLocation" => "/required",
178
- # "errors" => { "required" => "\"name\" is a required property" } },
179
- # ...
180
- # ] }
181
-
182
- # Hierarchical output (nested tree following schema structure)
181
+ # => {valid: false,
182
+ # details: [
183
+ # {valid: false, evaluationPath: "", schemaLocation: "", instanceLocation: ""},
184
+ # {valid: true, evaluationPath: "/type", schemaLocation: "/type", instanceLocation: ""},
185
+ # {valid: false, evaluationPath: "/required", schemaLocation: "/required",
186
+ # instanceLocation: "",
187
+ # errors: {"required" => "\"name\" is a required property"}},
188
+ # {valid: false, evaluationPath: "/properties", schemaLocation: "/properties",
189
+ # instanceLocation: "", droppedAnnotations: ["age"]},
190
+ # {valid: false, evaluationPath: "/properties/age", schemaLocation: "/properties/age",
191
+ # instanceLocation: "/age"},
192
+ # {valid: false, evaluationPath: "/properties/age/type",
193
+ # schemaLocation: "/properties/age/type", instanceLocation: "/age",
194
+ # errors: {"type" => "\"not_an_integer\" is not of type \"integer\""}}
195
+ # ]}
196
+ ```
197
+
198
+ **Hierarchical output** — nested tree following schema structure:
199
+
200
+ ```ruby
183
201
  evaluation.hierarchical
184
- # => { "valid" => false, "evaluationPath" => "", "instanceLocation" => "", "schemaLocation" => "",
185
- # "details" => [ ... ] }
202
+ # => {valid: false, evaluationPath: "", schemaLocation: "", instanceLocation: "",
203
+ # details: [
204
+ # {valid: true, evaluationPath: "/type", schemaLocation: "/type", instanceLocation: ""},
205
+ # {valid: false, evaluationPath: "/required", schemaLocation: "/required",
206
+ # instanceLocation: "",
207
+ # errors: {"required" => "\"name\" is a required property"}},
208
+ # {valid: false, evaluationPath: "/properties", schemaLocation: "/properties",
209
+ # instanceLocation: "", droppedAnnotations: ["age"],
210
+ # details: [
211
+ # {valid: false, evaluationPath: "/properties/age",
212
+ # schemaLocation: "/properties/age", instanceLocation: "/age",
213
+ # details: [
214
+ # {valid: false, evaluationPath: "/properties/age/type",
215
+ # schemaLocation: "/properties/age/type", instanceLocation: "/age",
216
+ # errors: {"type" => "\"not_an_integer\" is not of type \"integer\""}}
217
+ # ]}
218
+ # ]}
219
+ # ]}
220
+ ```
186
221
 
187
- # Collected errors across all nodes
222
+ **Collected errors** flat list of all errors across evaluation nodes:
223
+
224
+ ```ruby
188
225
  evaluation.errors
189
- # => [{ "schemaLocation" => "/required", "instanceLocation" => "",
190
- # "absoluteKeywordLocation" => nil, "error" => "\"name\" is a required property" }, ...]
226
+ # => [{schemaLocation: "/required", absoluteKeywordLocation: nil,
227
+ # instanceLocation: "", error: "\"name\" is a required property"},
228
+ # {schemaLocation: "/properties/age/type", absoluteKeywordLocation: nil,
229
+ # instanceLocation: "/age",
230
+ # error: "\"not_an_integer\" is not of type \"integer\""}]
231
+ ```
232
+
233
+ **Collected annotations** — flat list of annotations from successfully validated nodes.
234
+ When a node fails validation, its annotations appear as `droppedAnnotations` in the list/hierarchical output instead.
191
235
 
192
- # Collected annotations
193
- evaluation.annotations
194
- # => [{ "schemaLocation" => "/properties", "instanceLocation" => "",
195
- # "absoluteKeywordLocation" => nil, "annotations" => ["age"] }]
236
+ ```ruby
237
+ valid_eval = validator.evaluate({ "name" => "Alice", "age" => 30 })
238
+ valid_eval.annotations
239
+ # => [{schemaLocation: "/properties", absoluteKeywordLocation: nil,
240
+ # instanceLocation: "", annotations: ["age", "name"]}]
196
241
  ```
197
242
 
198
243
  ## Meta-Schema Validation
@@ -460,14 +505,12 @@ Valid draft symbols: `:draft4`, `:draft6`, `:draft7`, `:draft201909`, `:draft202
460
505
 
461
506
  `jsonschema` is designed for high performance, outperforming other Ruby JSON Schema validators in most scenarios:
462
507
 
463
- - **26-141x** faster than `json_schemer` for complex schemas and large instances
464
- - **174-535x** faster than `json-schema` where supported
465
- - **7-125x** faster than `rj_schema` (RapidJSON/C++)
508
+ - **30-117x** faster than `json_schemer` for complex schemas and large instances
509
+ - **206-473x** faster than `json-schema` where supported
510
+ - **7-118x** faster than `rj_schema` (RapidJSON/C++)
466
511
 
467
512
  For detailed benchmarks, see our [full performance comparison](https://github.com/Stranger6667/jsonschema/blob/master/crates/jsonschema-rb/BENCHMARKS.md).
468
513
 
469
- **Tips:** Reuse validators. Use `valid?` for boolean checks (short-circuits on first error).
470
-
471
514
  ## Acknowledgements
472
515
 
473
516
  This library draws API design inspiration from the Python [`jsonschema`](https://github.com/python-jsonschema/jsonschema) package. We're grateful to the Python `jsonschema` maintainers and contributors for their pioneering work in JSON Schema validation.
@@ -667,9 +667,9 @@ dependencies = [
667
667
 
668
668
  [[package]]
669
669
  name = "jsonschema"
670
- version = "0.42.0"
670
+ version = "0.42.1"
671
671
  source = "registry+https://github.com/rust-lang/crates.io-index"
672
- checksum = "c56489aa781cefb9c10edebf4469cf29cddfd6695408b6158acfec49cda73480"
672
+ checksum = "6103dcd3815c9bd04239a6d0343dac2b7a18ee260e800d0a6e3eb5b9333504fb"
673
673
  dependencies = [
674
674
  "ahash",
675
675
  "bytecount",
@@ -697,7 +697,7 @@ dependencies = [
697
697
 
698
698
  [[package]]
699
699
  name = "jsonschema-rb-ext"
700
- version = "0.42.0"
700
+ version = "0.42.1"
701
701
  dependencies = [
702
702
  "jsonschema",
703
703
  "magnus",
@@ -1044,9 +1044,9 @@ dependencies = [
1044
1044
 
1045
1045
  [[package]]
1046
1046
  name = "referencing"
1047
- version = "0.42.0"
1047
+ version = "0.42.1"
1048
1048
  source = "registry+https://github.com/rust-lang/crates.io-index"
1049
- checksum = "1871aca1d163bb628f2282b79c169e9ad3b4aeda58ecea174ec4d6bddfdfa375"
1049
+ checksum = "1a76b0c93f3dd49da2900cfb3c6b883602471a0e3e34b1578a3310ca1269d418"
1050
1050
  dependencies = [
1051
1051
  "ahash",
1052
1052
  "fluent-uri",
@@ -1,6 +1,6 @@
1
1
  [package]
2
2
  name = "jsonschema-rb-ext"
3
- version = "0.42.0"
3
+ version = "0.42.1"
4
4
  edition = "2021"
5
5
  publish = false
6
6
 
@@ -10,10 +10,10 @@ name = "jsonschema_rb"
10
10
  path = "../../src/lib.rs"
11
11
 
12
12
  [dependencies]
13
- jsonschema = { version = "0.42.0", default-features = false, features = ["arbitrary-precision", "resolve-http", "resolve-file", "tls-ring"] }
13
+ jsonschema = { version = "0.42.1", default-features = false, features = ["arbitrary-precision", "resolve-http", "resolve-file", "tls-ring"] }
14
14
  magnus = { version = "0.8", features = ["rb-sys"] }
15
15
  rb-sys = "0.9"
16
- referencing = "0.42.0"
16
+ referencing = "0.42.1"
17
17
  serde = { version = "1", features = ["derive"] }
18
18
  serde_json = { version = "1", features = ["arbitrary_precision"] }
19
19
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module JSONSchema
4
- VERSION = "0.42.0"
4
+ VERSION = "0.42.1"
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jsonschema_rs
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.42.0
4
+ version: 0.42.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dmitry Dygalo