jsonschema_rs 0.50.1 → 0.52.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: 60286fc7bf517866e7429a90e42fa4505ea769ba9728c1d03fcd1dafe2ff63ce
4
+ data.tar.gz: 6aaea36a12a38414cac3ec8af674b2b944cfd451dcf682488525f62fe12ee98e
5
5
  SHA512:
6
- metadata.gz: 6fb0b5f41da70c05b4ce56f721de089ee215485edc38160c9b0770ed70f66d7672d6db55c6a573def409079b06fa0c4e9e218adc2bfe750e946a9da6cace439d
7
- data.tar.gz: d6614c068ca1f3f7eb8aede6a8b37321cad426f7b6158b7f870aab73fce44ceab7fa6afdef01617581571cce389281a206841ec1a34ad40e969b4b02759a0c23
6
+ metadata.gz: bb0c6f0d5db65db03bc05d11cd636d8fc37b9b61a33b3674da032de2ec1a31df43f595bc9c16964bace627362a699fb032e0d90f459d81a0f68222eb6e251f5d
7
+ data.tar.gz: 03a44cfe94869f6ccf039205ee42eedddf84cd11005b44f3d0b9db75efdaf2c63166a82d71332fc65e03cb41a959355737bbff7a9750c99a50ec061d0112ef1e
data/CHANGELOG.md CHANGED
@@ -2,6 +2,43 @@
2
2
 
3
3
  ## [Unreleased]
4
4
 
5
+ ## [0.52.0] - 2026-08-27
6
+
7
+ ### Added
8
+
9
+ - The `offline:` keyword argument, refusing to fetch references outside `registry:`.
10
+
11
+ ### Fixed
12
+
13
+ - Canonicalization not idempotent where a `patternProperties` `$ref` matches a key `properties` names.
14
+ - The `draft:` keyword argument and the `Draft201909Validator` / `Draft202012Validator` classes gating keywords on the vocabularies of the `$schema` they override, so the validator accepted every instance.
15
+ - `valid?` disagreeing with `validate!`, `each_error`, and `evaluate` on a schema that reaches its own `$ref` twice, one of them under `not`.
16
+
17
+ ## [0.51.0] - 2026-08-23
18
+
19
+ ### Added
20
+
21
+ - `vocabularies` option, declaring support for a vocabulary this library does not implement.
22
+
23
+ ### Fixed
24
+
25
+ - The `uniqueItems` length ceiling not reading an `items` or `contains` schema written as a `$ref`.
26
+ - The Draft 2020-12 Format-Assertion vocabulary read as an annotation, so a meta-schema requiring it accepted values its `format` rejects.
27
+ - An unrecognized `format` accepted under a meta-schema requiring the Format-Assertion vocabulary (it should be rejected).
28
+ - A meta-schema requiring a vocabulary this library does not implement accepted (it should be rejected).
29
+ - The Draft 2019-09 Format vocabulary declared `true` read as an annotation, so a meta-schema requiring it accepted values its `format` rejects.
30
+ - 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.
31
+ - A meta-schema without `$id` keeping its `$vocabulary` unread, so a schema written against it got every Draft 2020-12 vocabulary.
32
+ - A schema naming a bundled vocabulary meta-schema as its `$schema` rejected as an unknown meta-schema (it should build).
33
+ - The `regex` format reading the Rust regex dialect (it should read the ECMA-262 dialect in Unicode mode).
34
+ - The `uri-template` format rejecting an apostrophe in a literal (it should accept it, per RFC 6570 errata 6937).
35
+ - The `duration` format accepting weeks combined with a time part, such as `P1WT1H` (it should reject it).
36
+ - 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.
37
+
38
+ ### Performance
39
+
40
+ - Building `unevaluatedProperties` or `unevaluatedItems` over a deep `allOf` or `$ref` chain costs its depth instead of its square.
41
+
5
42
  ## [0.50.1] - 2026-08-22
6
43
 
7
44
  ### Changed
@@ -442,7 +479,9 @@
442
479
 
443
480
  - Initial public release
444
481
 
445
- [Unreleased]: https://github.com/Stranger6667/jsonschema/compare/ruby-v0.50.1...HEAD
482
+ [Unreleased]: https://github.com/Stranger6667/jsonschema/compare/ruby-v0.52.0...HEAD
483
+ [0.52.0]: https://github.com/Stranger6667/jsonschema/compare/ruby-v0.51.0...ruby-v0.52.0
484
+ [0.51.0]: https://github.com/Stranger6667/jsonschema/compare/ruby-v0.50.1...ruby-v0.51.0
446
485
  [0.50.1]: https://github.com/Stranger6667/jsonschema/compare/ruby-v0.50.0...ruby-v0.50.1
447
486
  [0.50.0]: https://github.com/Stranger6667/jsonschema/compare/ruby-v0.49.9...ruby-v0.50.0
448
487
  [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.52.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.52.0", default-features = false, features = ["magnus", "arbitrary-precision", "resolve-http", "resolve-file", "tls-ring", "macros", "idna"] }
18
18
  magnus = { version = "0.8", features = ["rb-sys"] }
19
19
  rb-sys = "0.9"
20
20
  serde = { workspace = true }
data/README.md CHANGED
@@ -49,7 +49,7 @@ end
49
49
  - 🌐 Remote reference fetching (network/file)
50
50
  - 🔧 Custom keywords and format validators
51
51
  - ✨ Meta-schema validation for schema documents
52
- - 📦 Schema bundling into Compound Schema Documents
52
+ - 📦 Schema bundling into Compound Schema Documents, and `$ref` dereferencing
53
53
  - 🧮 Experimental schema canonicalization
54
54
  - ♦️ Supports Ruby 3.2, 3.4 and 4.0
55
55
 
@@ -371,7 +371,7 @@ Compare a request schema new-against-old and a response schema old-against-new:
371
371
 
372
372
  Both operands must share one setup - the same draft, format policy, regular-expression engine and definitions - or `IncompatibleOperands` is raised. `UnsupportedOperand` means an operand is a `Raw` pass-through, and `UnsupportedResult` that the canonical form does not support the result. All three live under `JSONSchema::Canonical`.
373
373
 
374
- ## Schema Bundling
374
+ ## Schema Bundling and Dereferencing
375
375
 
376
376
  Produce a Compound Schema Document ([Appendix B](https://json-schema.org/draft/2020-12/json-schema-core#appendix-B)) by embedding all external `$ref` targets into a draft-appropriate container. The result validates identically to the original.
377
377
 
@@ -395,6 +395,12 @@ registry = JSONSchema::Registry.new([["https://example.com/address.json", addres
395
395
  bundled = JSONSchema.bundle(schema, registry: registry)
396
396
  ```
397
397
 
398
+ `dereference` instead replaces each `$ref` with the schema it points to, for consumers that do not resolve references. Circular references are left in place.
399
+
400
+ ```ruby
401
+ dereferenced = JSONSchema.dereference(schema, registry: registry)
402
+ ```
403
+
398
404
  ## Meta-Schema Validation
399
405
 
400
406
  Validate that a JSON Schema document is itself valid:
@@ -644,6 +650,7 @@ JSONSchema.valid?(schema, instance,
644
650
  formats: { "name" => proc }, # Custom format validators
645
651
  keywords: { "name" => Klass }, # Custom keyword validators
646
652
  registry: registry, # Pre-registered schemas
653
+ vocabularies: ["https://..."], # Vocabularies implemented by custom keywords
647
654
  pattern_options: opts, # RegexOptions or FancyRegexOptions
648
655
  email_options: opts, # EmailOptions
649
656
  http_options: opts # HttpOptions
@@ -269,9 +269,9 @@ dependencies = [
269
269
 
270
270
  [[package]]
271
271
  name = "fraction"
272
- version = "0.16.0"
272
+ version = "0.17.0"
273
273
  source = "registry+https://github.com/rust-lang/crates.io-index"
274
- checksum = "33fee0259ffdc3d7bd64438b6b08437884d4df5700f9cb8a23b079c3958ae578"
274
+ checksum = "e246562084dde8ebbcc943b261c406ce4f68e5032ec28029a251a47d6a295500"
275
275
  dependencies = [
276
276
  "num",
277
277
  "num-bigint",
@@ -693,9 +693,9 @@ dependencies = [
693
693
 
694
694
  [[package]]
695
695
  name = "jsonschema"
696
- version = "0.50.1"
696
+ version = "0.52.0"
697
697
  source = "registry+https://github.com/rust-lang/crates.io-index"
698
- checksum = "29b6bb4e22283b09119c671e57ac6a185e9a0c70c31585e56b729b626d877753"
698
+ checksum = "0ee5867390f14ee43278d8d05d3af5f5314eeccb4684e6049033f2ba4ae3d4ae"
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.52.0"
730
730
  source = "registry+https://github.com/rust-lang/crates.io-index"
731
- checksum = "000c297a4271d226040b519b13132ec685b0e5db6256e1dac53091c932232a81"
731
+ checksum = "31552147ec28242b841ab069f8ba32b2548d2a3ff7c47b0085078c5bc84c49de"
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.52.0"
740
740
  source = "registry+https://github.com/rust-lang/crates.io-index"
741
- checksum = "6d14c9603a90595803e9ad8a62487f8d19f31dcd3848e3b99cac44db21c1cada"
741
+ checksum = "fbdfa029e60c8f29b8069de429929f33b0da3109ad95f8428728a68bb6f2c0fc"
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.52.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.52.0"
773
773
  source = "registry+https://github.com/rust-lang/crates.io-index"
774
- checksum = "497fbf3b1ca53b1e23a253f636e88e7a2031387388b8140199a0f240fcadf647"
774
+ checksum = "1a7bbc0f53dcb425cf3bae539be26b406b7053e6995e34e4b04477091e600044"
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.52.0"
782
782
  source = "registry+https://github.com/rust-lang/crates.io-index"
783
- checksum = "b84ca3f39446973a810fc90fc2645ada8c24284f6deb009c78b776813973887d"
783
+ checksum = "0d3e24abcd5f7eff512eb6bb915ac67772f2e7142ae5b5ac67b4ac75bd417d46"
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.52.0"
1137
1137
  source = "registry+https://github.com/rust-lang/crates.io-index"
1138
- checksum = "7a0a32a2a2c2d7dd0ee54705b5fd641be73037271928f68e9b0e7205b71c9d30"
1138
+ checksum = "b6326ce79629af4702ac033666390011ccc70fe82ffedd62824d061f133bd10b"
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.52.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.52.0", default-features = false, features = ["magnus", "arbitrary-precision", "resolve-http", "resolve-file", "tls-ring", "macros", "idna"] }
14
14
  magnus = { version = "0.8", features = ["rb-sys"] }
15
15
  rb-sys = "0.9"
16
- referencing = "0.50.1"
16
+ referencing = "0.52.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.52.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/evaluation.rs CHANGED
@@ -26,7 +26,7 @@ impl Evaluation {
26
26
  }
27
27
 
28
28
  fn is_valid(&self) -> bool {
29
- self.inner.flag().valid
29
+ self.inner.is_valid()
30
30
  }
31
31
 
32
32
  /// Simplest output format — only a "valid" key.
@@ -95,10 +95,7 @@ impl Evaluation {
95
95
  }
96
96
 
97
97
  fn inspect(&self) -> String {
98
- format!(
99
- "#<JSONSchema::Evaluation valid={}>",
100
- self.inner.flag().valid
101
- )
98
+ format!("#<JSONSchema::Evaluation valid={}>", self.inner.is_valid())
102
99
  }
103
100
  }
104
101
 
data/src/lib.rs CHANGED
@@ -200,9 +200,11 @@ 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,
207
+ kw.offline,
206
208
  )
207
209
  }
208
210
 
data/src/options.rs CHANGED
@@ -36,6 +36,8 @@ 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");
40
+ define_rb_intern!(static KW_OFFLINE: "offline");
39
41
  define_rb_intern!(static KW_PATTERN_OPTIONS: "pattern_options");
40
42
  define_rb_intern!(static KW_EMAIL_OPTIONS: "email_options");
41
43
  define_rb_intern!(static KW_HTTP_OPTIONS: "http_options");
@@ -224,31 +226,39 @@ pub fn parse_draft_symbol(ruby: &Ruby, val: Value) -> Result<jsonschema::Draft,
224
226
 
225
227
  pub struct ExtractedKwargs {
226
228
  pub base: BaseKwargs,
229
+ pub vocabularies: Option<Vec<String>>,
227
230
  pub pattern_options: Option<Value>,
228
231
  pub email_options: Option<Value>,
229
232
  pub http_options: Option<Value>,
233
+ pub offline: Option<bool>,
230
234
  }
231
235
 
232
236
  pub fn extract_kwargs(_ruby: &Ruby, kw: RHash) -> Result<ExtractedKwargs, Error> {
237
+ let vocabularies = extract_vocabularies(&kw)?;
233
238
  let pattern_options = extract_and_delete(&kw, *KW_PATTERN_OPTIONS)?;
234
239
  let email_options = extract_and_delete(&kw, *KW_EMAIL_OPTIONS)?;
235
240
  let http_options = extract_and_delete(&kw, *KW_HTTP_OPTIONS)?;
241
+ let offline = extract_offline(&kw)?;
236
242
 
237
243
  let ids = base_option_ids();
238
244
  let base_kw: KwArgs<(), BaseKwargs, ()> = get_kwargs(kw, &[], &ids)?;
239
245
 
240
246
  Ok(ExtractedKwargs {
241
247
  base: base_kw.optional,
248
+ vocabularies,
242
249
  pattern_options,
243
250
  email_options,
244
251
  http_options,
252
+ offline,
245
253
  })
246
254
  }
247
255
 
248
256
  pub fn extract_evaluate_kwargs(_ruby: &Ruby, kw: RHash) -> Result<ExtractedKwargs, Error> {
257
+ let vocabularies = extract_vocabularies(&kw)?;
249
258
  let pattern_options = extract_and_delete(&kw, *KW_PATTERN_OPTIONS)?;
250
259
  let email_options = extract_and_delete(&kw, *KW_EMAIL_OPTIONS)?;
251
260
  let http_options = extract_and_delete(&kw, *KW_HTTP_OPTIONS)?;
261
+ let offline = extract_offline(&kw)?;
252
262
 
253
263
  let ids = base_option_ids_no_mask();
254
264
  let base_kw: KwArgs<(), BaseKwargsNoMask, ()> = get_kwargs(kw, &[], &ids)?;
@@ -275,16 +285,20 @@ pub fn extract_evaluate_kwargs(_ruby: &Ruby, kw: RHash) -> Result<ExtractedKwarg
275
285
  keywords,
276
286
  registry,
277
287
  ),
288
+ vocabularies,
278
289
  pattern_options,
279
290
  email_options,
280
291
  http_options,
292
+ offline,
281
293
  })
282
294
  }
283
295
 
284
296
  pub fn extract_kwargs_no_draft(_ruby: &Ruby, kw: RHash) -> Result<ExtractedKwargs, Error> {
297
+ let vocabularies = extract_vocabularies(&kw)?;
285
298
  let pattern_options = extract_and_delete(&kw, *KW_PATTERN_OPTIONS)?;
286
299
  let email_options = extract_and_delete(&kw, *KW_EMAIL_OPTIONS)?;
287
300
  let http_options = extract_and_delete(&kw, *KW_HTTP_OPTIONS)?;
301
+ let offline = extract_offline(&kw)?;
288
302
 
289
303
  let ids = base_option_ids_no_draft();
290
304
  let base_kw: KwArgs<(), BaseKwargsNoDraft, ()> = get_kwargs(kw, &[], &ids)?;
@@ -311,12 +325,26 @@ pub fn extract_kwargs_no_draft(_ruby: &Ruby, kw: RHash) -> Result<ExtractedKwarg
311
325
  keywords,
312
326
  registry,
313
327
  ),
328
+ vocabularies,
314
329
  pattern_options,
315
330
  email_options,
316
331
  http_options,
332
+ offline,
317
333
  })
318
334
  }
319
335
 
336
+ fn extract_offline(kw: &RHash) -> Result<Option<bool>, Error> {
337
+ extract_and_delete(kw, *KW_OFFLINE)?
338
+ .map(TryConvert::try_convert)
339
+ .transpose()
340
+ }
341
+
342
+ fn extract_vocabularies(kw: &RHash) -> Result<Option<Vec<String>>, Error> {
343
+ extract_and_delete(kw, *KW_VOCABULARIES)?
344
+ .map(TryConvert::try_convert)
345
+ .transpose()
346
+ }
347
+
320
348
  /// Extract a key from a Ruby Hash and remove it, returning None if not present or nil.
321
349
  fn extract_and_delete(hash: &RHash, key: StaticId) -> Result<Option<Value>, Error> {
322
350
  let val: Option<Value> = hash.delete(key.to_symbol())?;
@@ -482,10 +510,19 @@ pub fn make_options_from_kwargs(
482
510
  formats: Option<RHash>,
483
511
  keywords: Option<RHash>,
484
512
  registry_val: Option<Value>,
513
+ vocabularies: Option<Vec<String>>,
485
514
  pattern_options_val: Option<Value>,
486
515
  email_options_val: Option<Value>,
487
516
  http_options_val: Option<Value>,
517
+ offline: Option<bool>,
488
518
  ) -> Result<ParsedOptions<'_>, Error> {
519
+ let offline = offline.unwrap_or(false);
520
+ if offline && retriever_val.is_some() {
521
+ return Err(Error::new(
522
+ ruby.exception_arg_error(),
523
+ "`offline` cannot be used together with `retriever`",
524
+ ));
525
+ }
489
526
  let mut opts = jsonschema::options_for::<Magnus>();
490
527
  let mut registry = None;
491
528
  let mut retriever = None;
@@ -506,6 +543,10 @@ pub fn make_options_from_kwargs(
506
543
  opts = opts.should_ignore_unknown_formats(ignore);
507
544
  }
508
545
 
546
+ for vocabulary in vocabularies.into_iter().flatten() {
547
+ opts = opts.with_vocabulary(vocabulary);
548
+ }
549
+
509
550
  if let Some(uri) = base_uri {
510
551
  opts = opts.with_base_uri(uri);
511
552
  }
@@ -541,7 +582,7 @@ pub fn make_options_from_kwargs(
541
582
  })?;
542
583
  registry = Some(reg.inner.as_ref());
543
584
 
544
- if !retriever_was_provided && retriever.is_none() {
585
+ if !retriever_was_provided && retriever.is_none() && !offline {
545
586
  if let Some(registry_retriever_value) = reg.retriever_value(ruby) {
546
587
  if let Some(ret) = make_retriever(ruby, registry_retriever_value)? {
547
588
  compilation_roots
@@ -803,6 +844,10 @@ pub fn make_options_from_kwargs(
803
844
  .map_err(|e| Error::new(ruby.exception_arg_error(), e.to_string()))?;
804
845
  }
805
846
 
847
+ if offline {
848
+ opts = opts.offline();
849
+ }
850
+
806
851
  Ok(ParsedOptions {
807
852
  mask,
808
853
  options: opts,
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.52.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dmitry Dygalo