jsonschema_rs 0.49.6 → 0.49.7

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: fc5dcd36cc01a2cb2ef7c933f7f3334090a41e16a12b1609fed9a70bdffbb5ec
4
- data.tar.gz: e0756f39279f4c2be57811ed001623859264b4068e23817ee7e4c59d9efceb94
3
+ metadata.gz: 2b3388bbb4302ddf7e4c108df32d945f68074c7baac52e85aa19964bbd8d8cec
4
+ data.tar.gz: 9a833159377a6b7673007129536b9d3997f01b1d1cd4226a51efa358c5ef6daa
5
5
  SHA512:
6
- metadata.gz: 6596557fed8063bfb880120ff5a9e8fa7df17995af3cbcad630a6b3839be3cf7d2de5ea57e4bc12f66f34da4dde189129b4a033aeb5b81e602caf278667be511
7
- data.tar.gz: 9766e90b8b0d157ba2820d57c127091455a44920667bda2c6bc5716ca2d3df02969baf1e34a0a8d626f0cae73c2e81a78a24754e28ed767f600e99939fa387ec
6
+ metadata.gz: dec67420394656cbbaf899553338fa8525680018f548ba94470713bb66a057f6361cc4d93b98763b3c739233eab7df7bfb954eae2d9745fffd41a300df361b9a
7
+ data.tar.gz: 418f555ee5c68ed4a4932e6c9230ee0a8e3e5e8b5c92739d9007c959b305d99f68e272fc5cda0b2114751e50146528d478bf9c3cfaefb44399ddb97677fa8c23
data/CHANGELOG.md CHANGED
@@ -2,6 +2,41 @@
2
2
 
3
3
  ## [Unreleased]
4
4
 
5
+ ## [0.49.7] - 2026-08-08
6
+
7
+ ### Added
8
+
9
+ - `retriever`, `registry`, and `base_uri` keyword arguments to `JSONSchema.canonicalize`.
10
+ - Canonicalization of a `oneOf` whose branches name disjoint targets, which degrades to a union.
11
+ - Canonicalization of a vacuous `patternProperties` entry beside schema-valued `additionalProperties`, where matching keys escape its value constraint.
12
+ - Canonicalization of a Draft 4 closed pattern map with a reference nested under a property.
13
+ - Canonicalization of Draft 4 closed pattern maps that meet through an applicator.
14
+ - The complement of a reference back to a target already being negated, which stays symbolic instead of declining.
15
+ - `CanonicalSchema#definition` resolving `#` to the document the schema was read against.
16
+
17
+ ### Performance
18
+
19
+ - Up to 150x faster canonicalization of `not` over a union of many branches.
20
+ - 2% faster emission of canonical schemas, which no longer formats copied string values.
21
+ - 5% faster emission of canonical schemas, which no longer formats object keys while copying them.
22
+ - Up to 12% faster canonicalization of schemas that repeatedly intersect the same branches.
23
+ - 13% faster canonicalization of a non-dynamic OpenAPI document, which no longer scans every schema object for dynamic references.
24
+ - Faster canonicalization of schemas with local `$defs` references, which avoid decoding unescaped definition names.
25
+ - 23% faster canonicalization of an object whose keys a finite property-name set spells.
26
+ - 3% faster intersection of schemas where one side constrains nothing.
27
+ - Up to 31x faster canonicalization of a `oneOf` whose many branches overlap.
28
+ - Up to 14x faster canonicalization of a union whose object branches share no values.
29
+ - 7% faster canonicalization of schemas that reach the same pair of nodes repeatedly.
30
+ - 5% faster canonicalization of objects, whose property maps no longer reach the allocator.
31
+ - Up to 8% faster canonicalization of schemas that reach `true` and `false` subschemas repeatedly.
32
+ - 2% faster canonicalization of schemas that assert known string formats.
33
+
34
+ ### Fixed
35
+
36
+ - `CanonicalSchema#definition` and `CanonicalSchema#definitions` handing out a target that names the document root without that document, where `#` points at the target instead.
37
+ - An `items` tail beyond an array's length ceiling surviving canonicalization, where it governs no element.
38
+ - `CanonicalSchema#to_json_schema` leaving the document root out of a node emitted below it, where `#` points at that node instead.
39
+
5
40
  ## [0.49.6] - 2026-08-06
6
41
 
7
42
  ### Added
@@ -327,7 +362,8 @@
327
362
 
328
363
  - Initial public release
329
364
 
330
- [Unreleased]: https://github.com/Stranger6667/jsonschema/compare/ruby-v0.49.6...HEAD
365
+ [Unreleased]: https://github.com/Stranger6667/jsonschema/compare/ruby-v0.49.7...HEAD
366
+ [0.49.7]: https://github.com/Stranger6667/jsonschema/compare/ruby-v0.49.6...ruby-v0.49.7
331
367
  [0.49.6]: https://github.com/Stranger6667/jsonschema/compare/ruby-v0.49.5...ruby-v0.49.6
332
368
  [0.49.5]: https://github.com/Stranger6667/jsonschema/compare/ruby-v0.49.4...ruby-v0.49.5
333
369
  [0.49.4]: https://github.com/Stranger6667/jsonschema/compare/ruby-v0.49.3...ruby-v0.49.4
data/Cargo.toml CHANGED
@@ -1,6 +1,6 @@
1
1
  [package]
2
2
  name = "jsonschema-rb"
3
- version = "0.49.6"
3
+ version = "0.49.7"
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.6", default-features = false, features = ["magnus", "arbitrary-precision", "resolve-http", "resolve-file", "tls-ring", "macros"] }
16
+ jsonschema = { version = "0.49.7", 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.6"
696
+ version = "0.49.7"
697
697
  source = "registry+https://github.com/rust-lang/crates.io-index"
698
- checksum = "7e17384278234b10419a63c93fc85695ac9fc2da0833e3c59167f9986499590c"
698
+ checksum = "ca4b985be36e5b3d15162b16ca94ac18c2a0514f5598b23b9d769895cb56bc3c"
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.6"
729
+ version = "0.49.7"
730
730
  source = "registry+https://github.com/rust-lang/crates.io-index"
731
- checksum = "c76669fda3185c230671e06740af90404301d31ee5f8375cc0baea4b1d53f01a"
731
+ checksum = "de1ff79046715d10fe5fd795c0f562d8f2e41f470bed5fcad74a0c9f5fd5a6b8"
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.6"
739
+ version = "0.49.7"
740
740
  source = "registry+https://github.com/rust-lang/crates.io-index"
741
- checksum = "398e6baeee7f5a5825f80945cc324a385fdec9812516cfd37703822ef46cf80b"
741
+ checksum = "8888005b18cbb6b61b4cb5fb4ae5f20b45dde81ab59baf37897b4668ba58a6f3"
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.6"
758
+ version = "0.49.7"
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.6"
771
+ version = "0.49.7"
772
772
  source = "registry+https://github.com/rust-lang/crates.io-index"
773
- checksum = "ac634e339e73bf9629f6fb207f7b064d872253ae3b3f5c6e0ce8fd762b16e40f"
773
+ checksum = "614c05e01260d4532d9ad28d66185fa1d93d015c5d610cde70d4b7143d7fb98f"
774
774
  dependencies = [
775
775
  "regex-syntax",
776
776
  ]
777
777
 
778
778
  [[package]]
779
779
  name = "jsonschema-value"
780
- version = "0.49.6"
780
+ version = "0.49.7"
781
781
  source = "registry+https://github.com/rust-lang/crates.io-index"
782
- checksum = "92b8e258eb4515a3fc912a9c46e3987040dc07280592280097ea2085527870b8"
782
+ checksum = "8602a6850f24cf05c518f58c9b8d08e32a28b9848115c8e193693db0952353f6"
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.6"
1135
+ version = "0.49.7"
1136
1136
  source = "registry+https://github.com/rust-lang/crates.io-index"
1137
- checksum = "42902112f88a27e9afd5683e2ba31956fed2a5d43395f166dd26775ae9c0dedb"
1137
+ checksum = "0753550862a089302b186486dfb843f2d547415257d78c32ae0d169e4d6784d1"
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.6"
3
+ version = "0.49.7"
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.6", default-features = false, features = ["magnus", "arbitrary-precision", "resolve-http", "resolve-file", "tls-ring", "macros"] }
13
+ jsonschema = { version = "0.49.7", 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.6"
16
+ referencing = "0.49.7"
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.6"
4
+ VERSION = "0.49.7"
5
5
  end
data/sig/jsonschema.rbs CHANGED
@@ -202,7 +202,10 @@ module JSONSchema
202
202
  untyped schema,
203
203
  ?draft: draft?,
204
204
  ?validate_formats: bool?,
205
- ?pattern_options: (RegexOptions | FancyRegexOptions)?
205
+ ?pattern_options: (RegexOptions | FancyRegexOptions)?,
206
+ ?retriever: (^(String) -> untyped)?,
207
+ ?registry: Registry?,
208
+ ?base_uri: String?
206
209
  ) -> Canonical::CanonicalSchema
207
210
 
208
211
  # Create a validator with auto-detected draft version.
data/src/canonical.rs CHANGED
@@ -15,7 +15,12 @@ use magnus::{
15
15
  };
16
16
 
17
17
  use crate::{
18
- options::{extract_pattern_options, parse_draft_symbol, RbPatternOptions},
18
+ options::{
19
+ extract_pattern_options, parse_draft_symbol, RbPatternOptions, KW_BASE_URI, KW_REGISTRY,
20
+ KW_RETRIEVER,
21
+ },
22
+ registry::Registry,
23
+ retriever::make_retriever,
19
24
  ser::{to_schema_value, value_to_ruby},
20
25
  static_id::define_rb_intern,
21
26
  };
@@ -24,8 +29,18 @@ define_rb_intern!(static CANONICAL_KW_DRAFT: "draft");
24
29
  define_rb_intern!(static CANONICAL_KW_VALIDATE_FORMATS: "validate_formats");
25
30
  define_rb_intern!(static CANONICAL_KW_PATTERN_OPTIONS: "pattern_options");
26
31
 
27
- type CanonicalKwArgs =
28
- magnus::scan_args::KwArgs<(), (Option<Value>, Option<bool>, Option<Value>), ()>;
32
+ type CanonicalKwArgs = magnus::scan_args::KwArgs<
33
+ (),
34
+ (
35
+ Option<Value>,
36
+ Option<bool>,
37
+ Option<Value>,
38
+ Option<Value>,
39
+ Option<Value>,
40
+ Option<String>,
41
+ ),
42
+ (),
43
+ >;
29
44
 
30
45
  macro_rules! canonical_error_class {
31
46
  ($static_name:ident, $class_name:literal) => {
@@ -1274,9 +1289,13 @@ fn canonicalize(ruby: &Ruby, args: &[Value]) -> Result<Value, Error> {
1274
1289
  *CANONICAL_KW_DRAFT,
1275
1290
  *CANONICAL_KW_VALIDATE_FORMATS,
1276
1291
  *CANONICAL_KW_PATTERN_OPTIONS,
1292
+ *KW_RETRIEVER,
1293
+ *KW_REGISTRY,
1294
+ *KW_BASE_URI,
1277
1295
  ],
1278
1296
  )?;
1279
- let (draft_val, validate_formats, pattern_options) = base_kwargs.optional;
1297
+ let (draft_val, validate_formats, pattern_options, retriever_val, registry_val, base_uri) =
1298
+ base_kwargs.optional;
1280
1299
 
1281
1300
  let schema_value = to_schema_value(ruby, schema_arg)?;
1282
1301
  let mut options = jsonschema::canonical::options();
@@ -1292,6 +1311,34 @@ fn canonicalize(ruby: &Ruby, args: &[Value]) -> Result<Value, Error> {
1292
1311
  RbPatternOptions::Regex(inner) => options = options.with_pattern_options(inner),
1293
1312
  }
1294
1313
  }
1314
+ let mut has_retriever = false;
1315
+ if let Some(val) = retriever_val {
1316
+ if let Some(retriever) = make_retriever(ruby, val)? {
1317
+ options = options.with_retriever(retriever);
1318
+ has_retriever = true;
1319
+ }
1320
+ }
1321
+ if let Some(val) = registry_val {
1322
+ if !val.is_nil() {
1323
+ let registry: &Registry = TryConvert::try_convert(val).map_err(|_| {
1324
+ Error::new(
1325
+ ruby.exception_type_error(),
1326
+ "registry must be a JSONSchema::Registry instance",
1327
+ )
1328
+ })?;
1329
+ if !has_retriever {
1330
+ if let Some(value) = registry.retriever_value(ruby) {
1331
+ if let Some(retriever) = make_retriever(ruby, value)? {
1332
+ options = options.with_retriever(retriever);
1333
+ }
1334
+ }
1335
+ }
1336
+ options = options.with_registry(registry.inner.as_ref());
1337
+ }
1338
+ }
1339
+ if let Some(base_uri) = base_uri {
1340
+ options = options.with_base_uri(base_uri);
1341
+ }
1295
1342
  options
1296
1343
  .canonicalize(&schema_value)
1297
1344
  .map(|inner| ruby.obj_wrap(RbCanonicalSchema { inner }).as_value())
data/src/options.rs CHANGED
@@ -30,8 +30,8 @@ define_rb_intern!(static KW_DRAFT: "draft");
30
30
  define_rb_intern!(static KW_VALIDATE_FORMATS: "validate_formats");
31
31
  define_rb_intern!(static KW_IGNORE_UNKNOWN_FORMATS: "ignore_unknown_formats");
32
32
  define_rb_intern!(static KW_MASK: "mask");
33
- define_rb_intern!(static KW_BASE_URI: "base_uri");
34
- define_rb_intern!(static KW_RETRIEVER: "retriever");
33
+ define_rb_intern!(pub(crate) static KW_BASE_URI: "base_uri");
34
+ define_rb_intern!(pub(crate) static KW_RETRIEVER: "retriever");
35
35
  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");
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.6
4
+ version: 0.49.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dmitry Dygalo