jsonschema_rs 0.50.1 → 0.51.0

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: 7acba28bc0257f16171af9a56176f5278c09c28431fca51617d325cde3a6798f
4
- data.tar.gz: 6c87343882695b9c1e1e5a1fdbc2a66cbabc33a5f0dee58a30b5d6dee1643210
3
+ metadata.gz: 7cc0c8312d2b960d018cd1a8eda7e8db2ae74eee48bfd4328e3040e479db2a9d
4
+ data.tar.gz: 9149b6d196c3c7ca1b27ed2d12c433b2cdcc46ab1f665aea3e04e3186e901ede
5
5
  SHA512:
6
- metadata.gz: 6fb0b5f41da70c05b4ce56f721de089ee215485edc38160c9b0770ed70f66d7672d6db55c6a573def409079b06fa0c4e9e218adc2bfe750e946a9da6cace439d
7
- data.tar.gz: d6614c068ca1f3f7eb8aede6a8b37321cad426f7b6158b7f870aab73fce44ceab7fa6afdef01617581571cce389281a206841ec1a34ad40e969b4b02759a0c23
6
+ metadata.gz: c380d68065992826531bf42fa03d9a200fdf20cd2a43e5fd8f35212cdad2d88a4e4b3e67f806171c1a7dd6cc3b78eff2f2af19276ccb1bec91d6f0c658587e73
7
+ data.tar.gz: 4f73fb65388571245b79a05cba80b74be5dafd2ef70073310aacbcbb76ce63dbe71abd5e6f90140752dffca4b32d0693723b7e94dc88c9371d168b734bfee6aa
data/CHANGELOG.md CHANGED
@@ -2,6 +2,31 @@
2
2
 
3
3
  ## [Unreleased]
4
4
 
5
+ ## [0.51.0] - 2026-08-23
6
+
7
+ ### Added
8
+
9
+ - `vocabularies` option, declaring support for a vocabulary this library does not implement.
10
+
11
+ ### Fixed
12
+
13
+ - The `uniqueItems` length ceiling not reading an `items` or `contains` schema written as a `$ref`.
14
+ - The Draft 2020-12 Format-Assertion vocabulary read as an annotation, so a meta-schema requiring it accepted values its `format` rejects.
15
+ - An unrecognized `format` accepted under a meta-schema requiring the Format-Assertion vocabulary (it should be rejected).
16
+ - A meta-schema requiring a vocabulary this library does not implement accepted (it should be rejected).
17
+ - The Draft 2019-09 Format vocabulary declared `true` read as an annotation, so a meta-schema requiring it accepted values its `format` rejects.
18
+ - The bundled `https://json-schema.org/draft/2020-12/meta/format-assertion` meta-schema not declaring its vocabulary, so a schema written against it annotated `format` instead of asserting it.
19
+ - A meta-schema without `$id` keeping its `$vocabulary` unread, so a schema written against it got every Draft 2020-12 vocabulary.
20
+ - A schema naming a bundled vocabulary meta-schema as its `$schema` rejected as an unknown meta-schema (it should build).
21
+ - The `regex` format reading the Rust regex dialect (it should read the ECMA-262 dialect in Unicode mode).
22
+ - The `uri-template` format rejecting an apostrophe in a literal (it should accept it, per RFC 6570 errata 6937).
23
+ - The `duration` format accepting weeks combined with a time part, such as `P1WT1H` (it should reject it).
24
+ - Stack overflow compiling `unevaluatedProperties` or `unevaluatedItems` beside a `$ref` that cycles back to the node, written as `#`, through its `$id`, or through a chain of definitions.
25
+
26
+ ### Performance
27
+
28
+ - Building `unevaluatedProperties` or `unevaluatedItems` over a deep `allOf` or `$ref` chain costs its depth instead of its square.
29
+
5
30
  ## [0.50.1] - 2026-08-22
6
31
 
7
32
  ### Changed
@@ -442,7 +467,8 @@
442
467
 
443
468
  - Initial public release
444
469
 
445
- [Unreleased]: https://github.com/Stranger6667/jsonschema/compare/ruby-v0.50.1...HEAD
470
+ [Unreleased]: https://github.com/Stranger6667/jsonschema/compare/ruby-v0.51.0...HEAD
471
+ [0.51.0]: https://github.com/Stranger6667/jsonschema/compare/ruby-v0.50.1...ruby-v0.51.0
446
472
  [0.50.1]: https://github.com/Stranger6667/jsonschema/compare/ruby-v0.50.0...ruby-v0.50.1
447
473
  [0.50.0]: https://github.com/Stranger6667/jsonschema/compare/ruby-v0.49.9...ruby-v0.50.0
448
474
  [0.49.9]: https://github.com/Stranger6667/jsonschema/compare/ruby-v0.49.8...ruby-v0.49.9
data/Cargo.toml CHANGED
@@ -1,6 +1,6 @@
1
1
  [package]
2
2
  name = "jsonschema-rb"
3
- version = "0.50.1"
3
+ version = "0.51.0"
4
4
  edition = "2021"
5
5
  authors = ["Dmitry Dygalo <dmitry@dygalo.dev>"]
6
6
  license = "MIT"
@@ -14,7 +14,7 @@ crate-type = ["cdylib"]
14
14
 
15
15
  [dependencies]
16
16
  strum = "0.28.0"
17
- jsonschema = { version = "0.50.1", default-features = false, features = ["magnus", "arbitrary-precision", "resolve-http", "resolve-file", "tls-ring", "macros"] }
17
+ jsonschema = { version = "0.51.0", default-features = false, features = ["magnus", "arbitrary-precision", "resolve-http", "resolve-file", "tls-ring", "macros"] }
18
18
  magnus = { version = "0.8", features = ["rb-sys"] }
19
19
  rb-sys = "0.9"
20
20
  serde = { workspace = true }
data/README.md CHANGED
@@ -644,6 +644,7 @@ JSONSchema.valid?(schema, instance,
644
644
  formats: { "name" => proc }, # Custom format validators
645
645
  keywords: { "name" => Klass }, # Custom keyword validators
646
646
  registry: registry, # Pre-registered schemas
647
+ vocabularies: ["https://..."], # Vocabularies implemented by custom keywords
647
648
  pattern_options: opts, # RegexOptions or FancyRegexOptions
648
649
  email_options: opts, # EmailOptions
649
650
  http_options: opts # HttpOptions
@@ -693,9 +693,9 @@ dependencies = [
693
693
 
694
694
  [[package]]
695
695
  name = "jsonschema"
696
- version = "0.50.1"
696
+ version = "0.51.0"
697
697
  source = "registry+https://github.com/rust-lang/crates.io-index"
698
- checksum = "29b6bb4e22283b09119c671e57ac6a185e9a0c70c31585e56b729b626d877753"
698
+ checksum = "152999731bfbe0bb82d561550be73b0c31a9827d6ebe3fe96ad47563703b5328"
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.50.1"
729
+ version = "0.51.0"
730
730
  source = "registry+https://github.com/rust-lang/crates.io-index"
731
- checksum = "000c297a4271d226040b519b13132ec685b0e5db6256e1dac53091c932232a81"
731
+ checksum = "b2b1d072fffb43f056f6749cfe86d5fd5853cd0b8b139a05a83f616549b9a98d"
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.50.1"
739
+ version = "0.51.0"
740
740
  source = "registry+https://github.com/rust-lang/crates.io-index"
741
- checksum = "6d14c9603a90595803e9ad8a62487f8d19f31dcd3848e3b99cac44db21c1cada"
741
+ checksum = "9a710eb535fcbe18373b29254c6a9ca65de465c4228c04c3fdc7600d7b099651"
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.50.1"
758
+ version = "0.51.0"
759
759
  dependencies = [
760
760
  "jsonschema",
761
761
  "magnus",
@@ -769,18 +769,18 @@ dependencies = [
769
769
 
770
770
  [[package]]
771
771
  name = "jsonschema-regex"
772
- version = "0.50.1"
772
+ version = "0.51.0"
773
773
  source = "registry+https://github.com/rust-lang/crates.io-index"
774
- checksum = "497fbf3b1ca53b1e23a253f636e88e7a2031387388b8140199a0f240fcadf647"
774
+ checksum = "8cb2e614e1c610e31e947d53156e877340c718e053cfce0dfe9b9ce7beff4d31"
775
775
  dependencies = [
776
776
  "regex-syntax",
777
777
  ]
778
778
 
779
779
  [[package]]
780
780
  name = "jsonschema-value"
781
- version = "0.50.1"
781
+ version = "0.51.0"
782
782
  source = "registry+https://github.com/rust-lang/crates.io-index"
783
- checksum = "b84ca3f39446973a810fc90fc2645ada8c24284f6deb009c78b776813973887d"
783
+ checksum = "24373bc85409cb935a46af0ffb41294c5372c08cf9b0709913d908154cd10582"
784
784
  dependencies = [
785
785
  "ahash",
786
786
  "bytecount",
@@ -1133,9 +1133,9 @@ dependencies = [
1133
1133
 
1134
1134
  [[package]]
1135
1135
  name = "referencing"
1136
- version = "0.50.1"
1136
+ version = "0.51.0"
1137
1137
  source = "registry+https://github.com/rust-lang/crates.io-index"
1138
- checksum = "7a0a32a2a2c2d7dd0ee54705b5fd641be73037271928f68e9b0e7205b71c9d30"
1138
+ checksum = "0aff997fc7eecb671a947b0f73f5ce4bcb4ad3534fd5bff2dd752718a8107525"
1139
1139
  dependencies = [
1140
1140
  "ahash",
1141
1141
  "fluent-uri",
@@ -1,6 +1,6 @@
1
1
  [package]
2
2
  name = "jsonschema-rb-ext"
3
- version = "0.50.1"
3
+ version = "0.51.0"
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.50.1", default-features = false, features = ["magnus", "arbitrary-precision", "resolve-http", "resolve-file", "tls-ring", "macros"] }
13
+ jsonschema = { version = "0.51.0", 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.50.1"
16
+ referencing = "0.51.0"
17
17
  serde = { version = "1", features = ["derive"] }
18
18
  serde_json = { version = "1", features = ["arbitrary_precision"] }
19
19
  strum = "0.28.0"
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module JSONSchema
4
- VERSION = "0.50.1"
4
+ VERSION = "0.51.0"
5
5
  end
data/sig/jsonschema.rbs CHANGED
@@ -310,6 +310,7 @@ module JSONSchema
310
310
  untyped schema,
311
311
  ?validate_formats: bool?,
312
312
  ?ignore_unknown_formats: bool?,
313
+ ?vocabularies: Array[String]?,
313
314
  ?base_uri: String?,
314
315
  ?retriever: (^(String) -> untyped)?,
315
316
  ?mask: String?,
@@ -326,6 +327,7 @@ module JSONSchema
326
327
  untyped schema,
327
328
  ?validate_formats: bool?,
328
329
  ?ignore_unknown_formats: bool?,
330
+ ?vocabularies: Array[String]?,
329
331
  ?mask: ::String?,
330
332
  ?base_uri: ::String?,
331
333
  ?retriever: (^(::String) -> untyped)?,
@@ -371,6 +373,7 @@ module JSONSchema
371
373
  ?draft: draft?,
372
374
  ?validate_formats: bool?,
373
375
  ?ignore_unknown_formats: bool?,
376
+ ?vocabularies: Array[String]?,
374
377
  ?base_uri: String?,
375
378
  ?retriever: (^(String) -> untyped)?,
376
379
  ?mask: String?,
@@ -389,6 +392,7 @@ module JSONSchema
389
392
  ?draft: draft?,
390
393
  ?validate_formats: bool?,
391
394
  ?ignore_unknown_formats: bool?,
395
+ ?vocabularies: Array[String]?,
392
396
  ?base_uri: String?,
393
397
  ?retriever: (^(String) -> untyped)?,
394
398
  ?mask: String?,
@@ -407,6 +411,7 @@ module JSONSchema
407
411
  ?draft: draft?,
408
412
  ?validate_formats: bool?,
409
413
  ?ignore_unknown_formats: bool?,
414
+ ?vocabularies: Array[String]?,
410
415
  ?base_uri: String?,
411
416
  ?retriever: (^(String) -> untyped)?,
412
417
  ?mask: String?,
@@ -423,6 +428,7 @@ module JSONSchema
423
428
  ?draft: draft?,
424
429
  ?validate_formats: bool?,
425
430
  ?ignore_unknown_formats: bool?,
431
+ ?vocabularies: Array[String]?,
426
432
  ?base_uri: String?,
427
433
  ?retriever: (^(String) -> untyped)?,
428
434
  ?mask: String?,
@@ -441,6 +447,7 @@ module JSONSchema
441
447
  ?draft: draft?,
442
448
  ?validate_formats: bool?,
443
449
  ?ignore_unknown_formats: bool?,
450
+ ?vocabularies: Array[String]?,
444
451
  ?base_uri: String?,
445
452
  ?retriever: (^(String) -> untyped)?,
446
453
  ?formats: Hash[String, ^(String) -> bool]?,
data/src/lib.rs CHANGED
@@ -200,6 +200,7 @@ fn build_parsed_options(
200
200
  formats,
201
201
  keywords,
202
202
  registry,
203
+ kw.vocabularies,
203
204
  kw.pattern_options,
204
205
  kw.email_options,
205
206
  kw.http_options,
data/src/options.rs CHANGED
@@ -36,6 +36,7 @@ define_rb_intern!(static KW_FORMATS: "formats");
36
36
  define_rb_intern!(static KW_KEYWORDS: "keywords");
37
37
  define_rb_intern!(pub(crate) static KW_REGISTRY: "registry");
38
38
  // Extra kwarg names (extracted before get_kwargs)
39
+ define_rb_intern!(static KW_VOCABULARIES: "vocabularies");
39
40
  define_rb_intern!(static KW_PATTERN_OPTIONS: "pattern_options");
40
41
  define_rb_intern!(static KW_EMAIL_OPTIONS: "email_options");
41
42
  define_rb_intern!(static KW_HTTP_OPTIONS: "http_options");
@@ -224,12 +225,14 @@ pub fn parse_draft_symbol(ruby: &Ruby, val: Value) -> Result<jsonschema::Draft,
224
225
 
225
226
  pub struct ExtractedKwargs {
226
227
  pub base: BaseKwargs,
228
+ pub vocabularies: Option<Vec<String>>,
227
229
  pub pattern_options: Option<Value>,
228
230
  pub email_options: Option<Value>,
229
231
  pub http_options: Option<Value>,
230
232
  }
231
233
 
232
234
  pub fn extract_kwargs(_ruby: &Ruby, kw: RHash) -> Result<ExtractedKwargs, Error> {
235
+ let vocabularies = extract_vocabularies(&kw)?;
233
236
  let pattern_options = extract_and_delete(&kw, *KW_PATTERN_OPTIONS)?;
234
237
  let email_options = extract_and_delete(&kw, *KW_EMAIL_OPTIONS)?;
235
238
  let http_options = extract_and_delete(&kw, *KW_HTTP_OPTIONS)?;
@@ -239,6 +242,7 @@ pub fn extract_kwargs(_ruby: &Ruby, kw: RHash) -> Result<ExtractedKwargs, Error>
239
242
 
240
243
  Ok(ExtractedKwargs {
241
244
  base: base_kw.optional,
245
+ vocabularies,
242
246
  pattern_options,
243
247
  email_options,
244
248
  http_options,
@@ -246,6 +250,7 @@ pub fn extract_kwargs(_ruby: &Ruby, kw: RHash) -> Result<ExtractedKwargs, Error>
246
250
  }
247
251
 
248
252
  pub fn extract_evaluate_kwargs(_ruby: &Ruby, kw: RHash) -> Result<ExtractedKwargs, Error> {
253
+ let vocabularies = extract_vocabularies(&kw)?;
249
254
  let pattern_options = extract_and_delete(&kw, *KW_PATTERN_OPTIONS)?;
250
255
  let email_options = extract_and_delete(&kw, *KW_EMAIL_OPTIONS)?;
251
256
  let http_options = extract_and_delete(&kw, *KW_HTTP_OPTIONS)?;
@@ -275,6 +280,7 @@ pub fn extract_evaluate_kwargs(_ruby: &Ruby, kw: RHash) -> Result<ExtractedKwarg
275
280
  keywords,
276
281
  registry,
277
282
  ),
283
+ vocabularies,
278
284
  pattern_options,
279
285
  email_options,
280
286
  http_options,
@@ -282,6 +288,7 @@ pub fn extract_evaluate_kwargs(_ruby: &Ruby, kw: RHash) -> Result<ExtractedKwarg
282
288
  }
283
289
 
284
290
  pub fn extract_kwargs_no_draft(_ruby: &Ruby, kw: RHash) -> Result<ExtractedKwargs, Error> {
291
+ let vocabularies = extract_vocabularies(&kw)?;
285
292
  let pattern_options = extract_and_delete(&kw, *KW_PATTERN_OPTIONS)?;
286
293
  let email_options = extract_and_delete(&kw, *KW_EMAIL_OPTIONS)?;
287
294
  let http_options = extract_and_delete(&kw, *KW_HTTP_OPTIONS)?;
@@ -311,12 +318,19 @@ pub fn extract_kwargs_no_draft(_ruby: &Ruby, kw: RHash) -> Result<ExtractedKwarg
311
318
  keywords,
312
319
  registry,
313
320
  ),
321
+ vocabularies,
314
322
  pattern_options,
315
323
  email_options,
316
324
  http_options,
317
325
  })
318
326
  }
319
327
 
328
+ fn extract_vocabularies(kw: &RHash) -> Result<Option<Vec<String>>, Error> {
329
+ extract_and_delete(kw, *KW_VOCABULARIES)?
330
+ .map(TryConvert::try_convert)
331
+ .transpose()
332
+ }
333
+
320
334
  /// Extract a key from a Ruby Hash and remove it, returning None if not present or nil.
321
335
  fn extract_and_delete(hash: &RHash, key: StaticId) -> Result<Option<Value>, Error> {
322
336
  let val: Option<Value> = hash.delete(key.to_symbol())?;
@@ -482,6 +496,7 @@ pub fn make_options_from_kwargs(
482
496
  formats: Option<RHash>,
483
497
  keywords: Option<RHash>,
484
498
  registry_val: Option<Value>,
499
+ vocabularies: Option<Vec<String>>,
485
500
  pattern_options_val: Option<Value>,
486
501
  email_options_val: Option<Value>,
487
502
  http_options_val: Option<Value>,
@@ -506,6 +521,10 @@ pub fn make_options_from_kwargs(
506
521
  opts = opts.should_ignore_unknown_formats(ignore);
507
522
  }
508
523
 
524
+ for vocabulary in vocabularies.into_iter().flatten() {
525
+ opts = opts.with_vocabulary(vocabulary);
526
+ }
527
+
509
528
  if let Some(uri) = base_uri {
510
529
  opts = opts.with_base_uri(uri);
511
530
  }
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.50.1
4
+ version: 0.51.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dmitry Dygalo