jsonschema_rs 0.49.3 → 0.49.4

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: 48dc9cf6305e242c8a686a6e1439fcc2d05ce1b2738bfdf1eb42394e05f16d03
4
- data.tar.gz: 9e828ed439bb3180094d3c2cdc1cbc0723ea71d385c2861278c7347493dfd900
3
+ metadata.gz: 1f9c13c1388f5e57ffff9783a04a15144954e15c0078414321bb7f699a7ebe6a
4
+ data.tar.gz: 866810b923d5654fc09def7495882a7e82bed9ac248594304885df21a9fb2699
5
5
  SHA512:
6
- metadata.gz: d41807f218f18e5435a4ec6e01326f5459076c78afd126844dcd03a982e1006514ec613333eac241853e8b83859410ab723f53ffa185f959cfd6209f8a4c6399
7
- data.tar.gz: 768c332d2d735999f58bde2a4947568d9e4e7c7cbf818e6ed8ae4177d890810490cf2494b5bfcea547fe7a0c7827775ba83192e465f77207581a9e40d6d21f1f
6
+ metadata.gz: 31bb5ae7145e6dec76c88ad04e38f354abd7cb8853df576e260503d783c324da7cdd921e5472a647354247cd8b370fa79c6ea1c8e653164349b35f13f8ef81e4
7
+ data.tar.gz: ea2c1a7ec8afed706a4d05504b3f69e58c2ee574b373b64eb828ff1f6c2b977b539bbe4aa45966250e4ea6bab234f9e86cfbd974b72d34c4bc3738f94c3836cd
data/CHANGELOG.md CHANGED
@@ -2,6 +2,30 @@
2
2
 
3
3
  ## [Unreleased]
4
4
 
5
+ ## [0.49.4] - 2026-08-04
6
+
7
+ ### Added
8
+
9
+ - Canonicalization of `not` a string format, which the string leaf carries as barred formats.
10
+ - Canonicalization of `not` an existential demand, which an array fails exactly when no element matches.
11
+ - Canonicalization of `not` a string value set, which the string leaf carries as excluded values.
12
+ - Canonicalization of `unevaluatedItems` beside `contains`, where the elements it matches are evaluated and the tail admits either.
13
+ - Canonicalization of `unevaluated*` beside `anyOf` or `oneOf`, where every branch evaluating the same keys or indexes pins what is left over.
14
+ - Canonicalization of `not` an array element schema, which an array fails exactly when one element violates it.
15
+ - `CanonicalSchema#intersect`, the values both schemas admit.
16
+ - `CanonicalSchema#negate`, the values a schema rejects.
17
+ - `CanonicalSchema#definition`, one reference target by URI.
18
+
19
+ ### Fixed
20
+
21
+ - An integer past `i64` admitted by a fractional bound `f64` rounds it onto, such as `-10000000000000000000000000` under `{"maximum": -10000000000000000000000000.1}`.
22
+ - An integer past `2^53` admitted by a bound `f64` rounds onto it, such as `9007199254740992` under `{"minimum": 9007199254740993}`.
23
+ - A `contains` subschema beside both `minContains` and `maxContains` overwriting a sibling keyword of the same name, such as `items`.
24
+
25
+ ### Performance
26
+
27
+ - `CanonicalSchema` hashing and equality cost the node instead of the whole document.
28
+
5
29
  ## [0.49.3] - 2026-08-02
6
30
 
7
31
  ### Added
@@ -262,7 +286,8 @@
262
286
 
263
287
  - Initial public release
264
288
 
265
- [Unreleased]: https://github.com/Stranger6667/jsonschema/compare/ruby-v0.49.3...HEAD
289
+ [Unreleased]: https://github.com/Stranger6667/jsonschema/compare/ruby-v0.49.4...HEAD
290
+ [0.49.4]: https://github.com/Stranger6667/jsonschema/compare/ruby-v0.49.3...ruby-v0.49.4
266
291
  [0.49.3]: https://github.com/Stranger6667/jsonschema/compare/ruby-v0.49.2...ruby-v0.49.3
267
292
  [0.49.2]: https://github.com/Stranger6667/jsonschema/compare/ruby-v0.49.1...ruby-v0.49.2
268
293
  [0.49.1]: https://github.com/Stranger6667/jsonschema/compare/ruby-v0.49.0...ruby-v0.49.1
data/Cargo.toml CHANGED
@@ -1,6 +1,6 @@
1
1
  [package]
2
2
  name = "jsonschema-rb"
3
- version = "0.49.3"
3
+ version = "0.49.4"
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.49.3", default-features = false, features = ["magnus", "arbitrary-precision", "resolve-http", "resolve-file", "tls-ring", "macros"] }
16
+ jsonschema = { version = "0.49.4", default-features = false, features = ["magnus", "arbitrary-precision", "resolve-http", "resolve-file", "tls-ring", "macros"] }
17
17
  magnus = { version = "0.8", features = ["rb-sys"] }
18
18
  rb-sys = "0.9"
19
19
  serde = { workspace = true }
@@ -693,9 +693,9 @@ dependencies = [
693
693
 
694
694
  [[package]]
695
695
  name = "jsonschema"
696
- version = "0.49.3"
696
+ version = "0.49.4"
697
697
  source = "registry+https://github.com/rust-lang/crates.io-index"
698
- checksum = "508004a5500f2e1f68af048f70feea2de86d35ab115d85716530860822aef397"
698
+ checksum = "257549c093d8f3d043337ba0d507e8eeace2447dfae3f0ee37eb0f57d3df7655"
699
699
  dependencies = [
700
700
  "ahash",
701
701
  "bytecount",
@@ -726,9 +726,9 @@ dependencies = [
726
726
 
727
727
  [[package]]
728
728
  name = "jsonschema-macros"
729
- version = "0.49.3"
729
+ version = "0.49.4"
730
730
  source = "registry+https://github.com/rust-lang/crates.io-index"
731
- checksum = "f4e131231bc18676df289bd7634d4353d5b36bced191928bfa2a2dcae91e44a0"
731
+ checksum = "b043434e5e987e02043a6fd8d0c2686c8db4fe31a37b373ef9b2a9b1f27b96c6"
732
732
  dependencies = [
733
733
  "jsonschema-macros-core",
734
734
  "proc-macro2",
@@ -736,9 +736,9 @@ dependencies = [
736
736
 
737
737
  [[package]]
738
738
  name = "jsonschema-macros-core"
739
- version = "0.49.3"
739
+ version = "0.49.4"
740
740
  source = "registry+https://github.com/rust-lang/crates.io-index"
741
- checksum = "75803a5014f912d5a8f3c8cc24531d19ea06dfadda75ddf1d15af629f7c8468c"
741
+ checksum = "892e0b0739e173cce25aef424366940b20eebe7dd29304a4b8484bbd1461cc8b"
742
742
  dependencies = [
743
743
  "fancy-regex",
744
744
  "indexmap",
@@ -755,7 +755,7 @@ dependencies = [
755
755
 
756
756
  [[package]]
757
757
  name = "jsonschema-rb-ext"
758
- version = "0.49.3"
758
+ version = "0.49.4"
759
759
  dependencies = [
760
760
  "jsonschema",
761
761
  "magnus",
@@ -768,18 +768,18 @@ dependencies = [
768
768
 
769
769
  [[package]]
770
770
  name = "jsonschema-regex"
771
- version = "0.49.3"
771
+ version = "0.49.4"
772
772
  source = "registry+https://github.com/rust-lang/crates.io-index"
773
- checksum = "5a8b30cafa78358ae6cd1494a7d6410b89530e28bf567f862c869c667e900d9f"
773
+ checksum = "474790e948498099d61ec85c10dc72d459d61298b7975eda7fb163af1934b134"
774
774
  dependencies = [
775
775
  "regex-syntax",
776
776
  ]
777
777
 
778
778
  [[package]]
779
779
  name = "jsonschema-value"
780
- version = "0.49.3"
780
+ version = "0.49.4"
781
781
  source = "registry+https://github.com/rust-lang/crates.io-index"
782
- checksum = "5526bd381d230af94908d07e6835a33fd82a465e12f5f1e9c81f5c2aa23b3c21"
782
+ checksum = "8212315eb8e0bc44959d1af653cd5ec515771a3cdca966cfc0a10999bff144b9"
783
783
  dependencies = [
784
784
  "ahash",
785
785
  "bytecount",
@@ -1132,9 +1132,9 @@ dependencies = [
1132
1132
 
1133
1133
  [[package]]
1134
1134
  name = "referencing"
1135
- version = "0.49.3"
1135
+ version = "0.49.4"
1136
1136
  source = "registry+https://github.com/rust-lang/crates.io-index"
1137
- checksum = "7af3eb523cce0df0af3c30d624b829b2dabd233172b5bc2615fcd03ceae8f746"
1137
+ checksum = "2bf1a74e036be2546c0c81cdfad6b2def6a25bf31c4e34a468037058d3bd05c6"
1138
1138
  dependencies = [
1139
1139
  "ahash",
1140
1140
  "fluent-uri",
@@ -1,6 +1,6 @@
1
1
  [package]
2
2
  name = "jsonschema-rb-ext"
3
- version = "0.49.3"
3
+ version = "0.49.4"
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.49.3", default-features = false, features = ["magnus", "arbitrary-precision", "resolve-http", "resolve-file", "tls-ring", "macros"] }
13
+ jsonschema = { version = "0.49.4", default-features = false, features = ["magnus", "arbitrary-precision", "resolve-http", "resolve-file", "tls-ring", "macros"] }
14
14
  magnus = { version = "0.8", features = ["rb-sys"] }
15
15
  rb-sys = "0.9"
16
- referencing = "0.49.3"
16
+ referencing = "0.49.4"
17
17
  serde = { version = "1", features = ["derive"] }
18
18
  serde_json = { version = "1", features = ["arbitrary_precision"] }
19
19
  zmij = "1"
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module JSONSchema
4
- VERSION = "0.49.3"
4
+ VERSION = "0.49.4"
5
5
  end
data/sig/jsonschema.rbs CHANGED
@@ -32,12 +32,21 @@ module JSONSchema
32
32
  class InvalidPattern < CanonicalizationError
33
33
  end
34
34
 
35
+ class IncompatibleOperands < CanonicalizationError
36
+ end
37
+
38
+ class UnmodeledOperand < CanonicalizationError
39
+ end
40
+
35
41
  # A schema reduced to canonical form: schemas accepting the same values share one form.
36
42
  class CanonicalSchema
37
43
  def to_json_schema: () -> untyped
38
44
  def draft: () -> JSONSchema::draft
39
45
  def kind: () -> kind
40
46
  def view: () -> view
47
+ def intersect: (CanonicalSchema other) -> CanonicalSchema
48
+ def negate: () -> CanonicalSchema?
49
+ def definition: (String uri) -> CanonicalSchema?
41
50
  def definitions: () -> Hash[String, CanonicalSchema]
42
51
  def satisfiable?: () -> bool
43
52
  def inspect: () -> String
@@ -77,6 +86,7 @@ module JSONSchema
77
86
  def formats: () -> Array[String]
78
87
  def content_media_types: () -> Array[String]
79
88
  def content_encodings: () -> Array[String]
89
+ def excluded: () -> Array[String]
80
90
  def inspect: () -> String
81
91
  def deconstruct_keys: (untyped keys) -> Hash[Symbol, untyped]
82
92
  end
data/src/canonical.rs CHANGED
@@ -47,6 +47,8 @@ macro_rules! canonical_error_class {
47
47
  canonical_error_class!(CANONICALIZATION_ERROR_CLASS, "CanonicalizationError");
48
48
  canonical_error_class!(INVALID_SCHEMA_TYPE_CLASS, "InvalidSchemaType");
49
49
  canonical_error_class!(INVALID_PATTERN_CLASS, "InvalidPattern");
50
+ canonical_error_class!(INCOMPATIBLE_OPERANDS_CLASS, "IncompatibleOperands");
51
+ canonical_error_class!(UNMODELED_OPERAND_CLASS, "UnmodeledOperand");
50
52
 
51
53
  fn canonicalization_error(ruby: &Ruby, error: CanonicalizationError) -> Error {
52
54
  if let CanonicalizationError::ValidationError(validation_error) = error {
@@ -60,6 +62,12 @@ fn canonicalization_error(ruby: &Ruby, error: CanonicalizationError) -> Error {
60
62
  CanonicalizationError::InvalidPattern { .. } => {
61
63
  Error::new(ruby.get_inner(&INVALID_PATTERN_CLASS), message)
62
64
  }
65
+ CanonicalizationError::IncompatibleOperands(_) => {
66
+ Error::new(ruby.get_inner(&INCOMPATIBLE_OPERANDS_CLASS), message)
67
+ }
68
+ CanonicalizationError::UnmodeledOperand => {
69
+ Error::new(ruby.get_inner(&UNMODELED_OPERAND_CLASS), message)
70
+ }
63
71
  // `ValidationError` returns above; future variants fall back to the base canonical error.
64
72
  _ => Error::new(ruby.get_inner(&CANONICALIZATION_ERROR_CLASS), message),
65
73
  }
@@ -141,8 +149,10 @@ impl RbCanonicalSchema {
141
149
  max_length: view.max_length,
142
150
  patterns: view.patterns,
143
151
  formats: view.formats,
152
+ excluded_formats: view.excluded_formats,
144
153
  content_media_types: view.content_media_types,
145
154
  content_encodings: view.content_encodings,
155
+ excluded: view.excluded,
146
156
  })
147
157
  .as_value(),
148
158
  CanonicalView::Number(view) => ruby
@@ -191,6 +201,29 @@ impl RbCanonicalSchema {
191
201
  }
192
202
  }
193
203
 
204
+ fn intersect(ruby: &Ruby, rb_self: &Self, other: &Self) -> Result<Value, Error> {
205
+ rb_self
206
+ .inner
207
+ .intersect(&other.inner)
208
+ .map(|inner| ruby.obj_wrap(RbCanonicalSchema { inner }).as_value())
209
+ .map_err(|error| canonicalization_error(ruby, error))
210
+ }
211
+
212
+ fn negate(ruby: &Ruby, rb_self: &Self) -> Option<Value> {
213
+ rb_self
214
+ .inner
215
+ .negate()
216
+ .map(|inner| ruby.obj_wrap(RbCanonicalSchema { inner }).as_value())
217
+ }
218
+
219
+ #[allow(clippy::needless_pass_by_value)]
220
+ fn definition(ruby: &Ruby, rb_self: &Self, uri: String) -> Option<Value> {
221
+ rb_self
222
+ .inner
223
+ .definition(&uri)
224
+ .map(|inner| ruby.obj_wrap(RbCanonicalSchema { inner }).as_value())
225
+ }
226
+
194
227
  fn definitions(ruby: &Ruby, rb_self: &Self) -> Result<RHash, Error> {
195
228
  let hash = ruby.hash_new();
196
229
  for (uri, target) in rb_self.inner.definitions() {
@@ -363,8 +396,10 @@ pub struct StringView {
363
396
  max_length: Option<serde_json::Number>,
364
397
  patterns: Vec<String>,
365
398
  formats: Vec<String>,
399
+ excluded_formats: Vec<String>,
366
400
  content_media_types: Vec<String>,
367
401
  content_encodings: Vec<String>,
402
+ excluded: Vec<String>,
368
403
  }
369
404
 
370
405
  impl DataTypeFunctions for StringView {}
@@ -386,6 +421,10 @@ impl StringView {
386
421
  strings_to_ruby(ruby, &rb_self.formats)
387
422
  }
388
423
 
424
+ fn excluded_formats(ruby: &Ruby, rb_self: &Self) -> Result<Value, Error> {
425
+ strings_to_ruby(ruby, &rb_self.excluded_formats)
426
+ }
427
+
389
428
  fn content_media_types(ruby: &Ruby, rb_self: &Self) -> Result<Value, Error> {
390
429
  strings_to_ruby(ruby, &rb_self.content_media_types)
391
430
  }
@@ -394,15 +433,21 @@ impl StringView {
394
433
  strings_to_ruby(ruby, &rb_self.content_encodings)
395
434
  }
396
435
 
436
+ fn excluded(ruby: &Ruby, rb_self: &Self) -> Result<Value, Error> {
437
+ strings_to_ruby(ruby, &rb_self.excluded)
438
+ }
439
+
397
440
  fn inspect(ruby: &Ruby, rb_self: &Self) -> Result<String, Error> {
398
441
  Ok(format!(
399
- "#<JSONSchema::Canonical::StringView min_length={} max_length={} patterns={} formats={} content_media_types={} content_encodings={}>",
442
+ "#<JSONSchema::Canonical::StringView min_length={} max_length={} patterns={} formats={} excluded_formats={} content_media_types={} content_encodings={} excluded={}>",
400
443
  Self::min_length(ruby, rb_self)?.inspect(),
401
444
  Self::max_length(ruby, rb_self)?.inspect(),
402
445
  Self::patterns(ruby, rb_self)?.inspect(),
403
446
  Self::formats(ruby, rb_self)?.inspect(),
447
+ Self::excluded_formats(ruby, rb_self)?.inspect(),
404
448
  Self::content_media_types(ruby, rb_self)?.inspect(),
405
- Self::content_encodings(ruby, rb_self)?.inspect()
449
+ Self::content_encodings(ruby, rb_self)?.inspect(),
450
+ Self::excluded(ruby, rb_self)?.inspect()
406
451
  ))
407
452
  }
408
453
 
@@ -412,6 +457,10 @@ impl StringView {
412
457
  hash.aset(ruby.sym_new("max_length"), Self::max_length(ruby, rb_self)?)?;
413
458
  hash.aset(ruby.sym_new("patterns"), Self::patterns(ruby, rb_self)?)?;
414
459
  hash.aset(ruby.sym_new("formats"), Self::formats(ruby, rb_self)?)?;
460
+ hash.aset(
461
+ ruby.sym_new("excluded_formats"),
462
+ Self::excluded_formats(ruby, rb_self)?,
463
+ )?;
415
464
  hash.aset(
416
465
  ruby.sym_new("content_media_types"),
417
466
  Self::content_media_types(ruby, rb_self)?,
@@ -420,6 +469,7 @@ impl StringView {
420
469
  ruby.sym_new("content_encodings"),
421
470
  Self::content_encodings(ruby, rb_self)?,
422
471
  )?;
472
+ hash.aset(ruby.sym_new("excluded"), Self::excluded(ruby, rb_self)?)?;
423
473
  Ok(hash)
424
474
  }
425
475
  }
@@ -1083,6 +1133,8 @@ pub(crate) fn init_canonical(ruby: &Ruby, module: &RModule) -> Result<(), Error>
1083
1133
  canonical_module.define_error("CanonicalizationError", ruby.exception_standard_error())?;
1084
1134
  canonical_module.define_error("InvalidSchemaType", base_error)?;
1085
1135
  canonical_module.define_error("InvalidPattern", base_error)?;
1136
+ canonical_module.define_error("IncompatibleOperands", base_error)?;
1137
+ canonical_module.define_error("UnmodeledOperand", base_error)?;
1086
1138
 
1087
1139
  let canonical_schema = canonical_module.define_class("CanonicalSchema", ruby.class_object())?;
1088
1140
  canonical_schema.define_method(
@@ -1102,6 +1154,9 @@ pub(crate) fn init_canonical(ruby: &Ruby, module: &RModule) -> Result<(), Error>
1102
1154
  method!(<RbCanonicalSchema as typed_data::Hash>::hash, 0),
1103
1155
  )?;
1104
1156
  canonical_schema.define_method("view", method!(RbCanonicalSchema::view, 0))?;
1157
+ canonical_schema.define_method("intersect", method!(RbCanonicalSchema::intersect, 1))?;
1158
+ canonical_schema.define_method("negate", method!(RbCanonicalSchema::negate, 0))?;
1159
+ canonical_schema.define_method("definition", method!(RbCanonicalSchema::definition, 1))?;
1105
1160
  canonical_schema.define_method("definitions", method!(RbCanonicalSchema::definitions, 0))?;
1106
1161
  canonical_schema.define_method("satisfiable?", method!(RbCanonicalSchema::satisfiable, 0))?;
1107
1162
 
@@ -1142,6 +1197,7 @@ pub(crate) fn init_canonical(ruby: &Ruby, module: &RModule) -> Result<(), Error>
1142
1197
  string_view.define_method("max_length", method!(StringView::max_length, 0))?;
1143
1198
  string_view.define_method("patterns", method!(StringView::patterns, 0))?;
1144
1199
  string_view.define_method("formats", method!(StringView::formats, 0))?;
1200
+ string_view.define_method("excluded_formats", method!(StringView::excluded_formats, 0))?;
1145
1201
  string_view.define_method(
1146
1202
  "content_media_types",
1147
1203
  method!(StringView::content_media_types, 0),
@@ -1150,6 +1206,7 @@ pub(crate) fn init_canonical(ruby: &Ruby, module: &RModule) -> Result<(), Error>
1150
1206
  "content_encodings",
1151
1207
  method!(StringView::content_encodings, 0),
1152
1208
  )?;
1209
+ string_view.define_method("excluded", method!(StringView::excluded, 0))?;
1153
1210
  string_view.define_method("inspect", method!(StringView::inspect, 0))?;
1154
1211
  string_view.define_method("deconstruct_keys", method!(StringView::deconstruct_keys, 1))?;
1155
1212
 
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.49.3
4
+ version: 0.49.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dmitry Dygalo