jsonschema_rs 0.49.5 → 0.49.6
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 +4 -4
- data/CHANGELOG.md +25 -1
- data/Cargo.toml +2 -2
- data/ext/jsonschema/Cargo.lock +13 -13
- data/ext/jsonschema/Cargo.toml +3 -3
- data/lib/jsonschema/version.rb +1 -1
- data/sig/jsonschema.rbs +19 -1
- data/src/canonical.rs +157 -9
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: fc5dcd36cc01a2cb2ef7c933f7f3334090a41e16a12b1609fed9a70bdffbb5ec
|
|
4
|
+
data.tar.gz: e0756f39279f4c2be57811ed001623859264b4068e23817ee7e4c59d9efceb94
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 6596557fed8063bfb880120ff5a9e8fa7df17995af3cbcad630a6b3839be3cf7d2de5ea57e4bc12f66f34da4dde189129b4a033aeb5b81e602caf278667be511
|
|
7
|
+
data.tar.gz: 9766e90b8b0d157ba2820d57c127091455a44920667bda2c6bc5716ca2d3df02969baf1e34a0a8d626f0cae73c2e81a78a24754e28ed767f600e99939fa387ec
|
data/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,29 @@
|
|
|
2
2
|
|
|
3
3
|
## [Unreleased]
|
|
4
4
|
|
|
5
|
+
## [0.49.6] - 2026-08-06
|
|
6
|
+
|
|
7
|
+
### Added
|
|
8
|
+
|
|
9
|
+
- Canonicalization of a negated `uniqueItems`, where the complement demands a repeated element under the length floor two elements imply.
|
|
10
|
+
- Canonicalization of a negated array tuple, where each position's complement stands under the length that reaches it.
|
|
11
|
+
- Canonicalization of `contains` demands sharing no value, where their counts add up into a length floor.
|
|
12
|
+
- `CanonicalSchema#negate` through references, where the complement of the resolved target takes the reference's place.
|
|
13
|
+
- Canonicalization of negated `propertyNames` and `additionalProperties`, where the complement spells the violating-key demand instead of a `not` residual.
|
|
14
|
+
- Canonicalization of negated `additionalProperties` under Draft 4, where the violating-key demand spells the closed property map.
|
|
15
|
+
- Canonicalization of `not` a reference, where the complement of the resolved target takes the pointer's place.
|
|
16
|
+
- Canonicalization of a negated `oneOf`, where the complement spells the values no branch admits beside the values two branches share.
|
|
17
|
+
- Canonicalization of negated `items` under Draft 4, where the violating-element demand spells the barred element schema.
|
|
18
|
+
|
|
19
|
+
### Changed
|
|
20
|
+
|
|
21
|
+
- `ArrayView` reports distinctness in three states, so an array demanding a repeated element reads apart from one demanding distinct elements.
|
|
22
|
+
|
|
23
|
+
### Fixed
|
|
24
|
+
|
|
25
|
+
- `CanonicalSchema#negate` keeping a root self-reference in the complement, where it points at the complement instead of the source.
|
|
26
|
+
- An `additionalItems` that tails no tuple keeping the whole document unmodeled under Draft 2020-12.
|
|
27
|
+
|
|
5
28
|
## [0.49.5] - 2026-08-05
|
|
6
29
|
|
|
7
30
|
### Added
|
|
@@ -304,7 +327,8 @@
|
|
|
304
327
|
|
|
305
328
|
- Initial public release
|
|
306
329
|
|
|
307
|
-
[Unreleased]: https://github.com/Stranger6667/jsonschema/compare/ruby-v0.49.
|
|
330
|
+
[Unreleased]: https://github.com/Stranger6667/jsonschema/compare/ruby-v0.49.6...HEAD
|
|
331
|
+
[0.49.6]: https://github.com/Stranger6667/jsonschema/compare/ruby-v0.49.5...ruby-v0.49.6
|
|
308
332
|
[0.49.5]: https://github.com/Stranger6667/jsonschema/compare/ruby-v0.49.4...ruby-v0.49.5
|
|
309
333
|
[0.49.4]: https://github.com/Stranger6667/jsonschema/compare/ruby-v0.49.3...ruby-v0.49.4
|
|
310
334
|
[0.49.3]: https://github.com/Stranger6667/jsonschema/compare/ruby-v0.49.2...ruby-v0.49.3
|
data/Cargo.toml
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
[package]
|
|
2
2
|
name = "jsonschema-rb"
|
|
3
|
-
version = "0.49.
|
|
3
|
+
version = "0.49.6"
|
|
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.
|
|
16
|
+
jsonschema = { version = "0.49.6", 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 }
|
data/ext/jsonschema/Cargo.lock
CHANGED
|
@@ -693,9 +693,9 @@ dependencies = [
|
|
|
693
693
|
|
|
694
694
|
[[package]]
|
|
695
695
|
name = "jsonschema"
|
|
696
|
-
version = "0.49.
|
|
696
|
+
version = "0.49.6"
|
|
697
697
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
698
|
-
checksum = "
|
|
698
|
+
checksum = "7e17384278234b10419a63c93fc85695ac9fc2da0833e3c59167f9986499590c"
|
|
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.
|
|
729
|
+
version = "0.49.6"
|
|
730
730
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
731
|
-
checksum = "
|
|
731
|
+
checksum = "c76669fda3185c230671e06740af90404301d31ee5f8375cc0baea4b1d53f01a"
|
|
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.
|
|
739
|
+
version = "0.49.6"
|
|
740
740
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
741
|
-
checksum = "
|
|
741
|
+
checksum = "398e6baeee7f5a5825f80945cc324a385fdec9812516cfd37703822ef46cf80b"
|
|
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.
|
|
758
|
+
version = "0.49.6"
|
|
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.
|
|
771
|
+
version = "0.49.6"
|
|
772
772
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
773
|
-
checksum = "
|
|
773
|
+
checksum = "ac634e339e73bf9629f6fb207f7b064d872253ae3b3f5c6e0ce8fd762b16e40f"
|
|
774
774
|
dependencies = [
|
|
775
775
|
"regex-syntax",
|
|
776
776
|
]
|
|
777
777
|
|
|
778
778
|
[[package]]
|
|
779
779
|
name = "jsonschema-value"
|
|
780
|
-
version = "0.49.
|
|
780
|
+
version = "0.49.6"
|
|
781
781
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
782
|
-
checksum = "
|
|
782
|
+
checksum = "92b8e258eb4515a3fc912a9c46e3987040dc07280592280097ea2085527870b8"
|
|
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.
|
|
1135
|
+
version = "0.49.6"
|
|
1136
1136
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
1137
|
-
checksum = "
|
|
1137
|
+
checksum = "42902112f88a27e9afd5683e2ba31956fed2a5d43395f166dd26775ae9c0dedb"
|
|
1138
1138
|
dependencies = [
|
|
1139
1139
|
"ahash",
|
|
1140
1140
|
"fluent-uri",
|
data/ext/jsonschema/Cargo.toml
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
[package]
|
|
2
2
|
name = "jsonschema-rb-ext"
|
|
3
|
-
version = "0.49.
|
|
3
|
+
version = "0.49.6"
|
|
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.
|
|
13
|
+
jsonschema = { version = "0.49.6", 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.
|
|
16
|
+
referencing = "0.49.6"
|
|
17
17
|
serde = { version = "1", features = ["derive"] }
|
|
18
18
|
serde_json = { version = "1", features = ["arbitrary_precision"] }
|
|
19
19
|
zmij = "1"
|
data/lib/jsonschema/version.rb
CHANGED
data/sig/jsonschema.rbs
CHANGED
|
@@ -121,7 +121,7 @@ module JSONSchema
|
|
|
121
121
|
class ArrayView
|
|
122
122
|
def min_items: () -> Integer?
|
|
123
123
|
def max_items: () -> Integer?
|
|
124
|
-
def
|
|
124
|
+
def distinctness: () -> (:unconstrained | :all_distinct | :some_repeated)
|
|
125
125
|
def prefix_items: () -> Array[CanonicalSchema]
|
|
126
126
|
def items: () -> CanonicalSchema?
|
|
127
127
|
def contains: () -> Array[ContainsView]
|
|
@@ -146,6 +146,24 @@ module JSONSchema
|
|
|
146
146
|
def property_names: () -> CanonicalSchema?
|
|
147
147
|
def properties: () -> Hash[String, CanonicalSchema]
|
|
148
148
|
def pattern_properties: () -> Hash[String, CanonicalSchema]
|
|
149
|
+
def additional_properties: () -> CanonicalSchema?
|
|
150
|
+
def violations: () -> Array[NameFailsView | UndeclaredValueFailsView]
|
|
151
|
+
def inspect: () -> String
|
|
152
|
+
def deconstruct_keys: (untyped keys) -> Hash[Symbol, untyped]
|
|
153
|
+
end
|
|
154
|
+
|
|
155
|
+
# Some key's name fails the schema.
|
|
156
|
+
class NameFailsView
|
|
157
|
+
def schema: () -> CanonicalSchema
|
|
158
|
+
def inspect: () -> String
|
|
159
|
+
def deconstruct_keys: (untyped keys) -> Hash[Symbol, untyped]
|
|
160
|
+
end
|
|
161
|
+
|
|
162
|
+
# Some key outside `names` and matching none of `patterns` has a value failing `additional`.
|
|
163
|
+
class UndeclaredValueFailsView
|
|
164
|
+
def names: () -> Array[String]
|
|
165
|
+
def patterns: () -> Array[String]
|
|
166
|
+
def additional: () -> CanonicalSchema
|
|
149
167
|
def inspect: () -> String
|
|
150
168
|
def deconstruct_keys: (untyped keys) -> Hash[Symbol, untyped]
|
|
151
169
|
end
|
data/src/canonical.rs
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
use jsonschema::{
|
|
2
2
|
canonical::{
|
|
3
3
|
CanonicalSchema, CanonicalView, CanonicalizationError, ContainsView as CoreContainsView,
|
|
4
|
+
ObjectViolationView as CoreObjectViolationView,
|
|
4
5
|
},
|
|
5
6
|
JsonType,
|
|
6
7
|
};
|
|
@@ -179,7 +180,7 @@ impl RbCanonicalSchema {
|
|
|
179
180
|
.obj_wrap(ArrayView {
|
|
180
181
|
min_items: view.min_items,
|
|
181
182
|
max_items: view.max_items,
|
|
182
|
-
|
|
183
|
+
distinctness: view.distinctness.as_str(),
|
|
183
184
|
prefix_items: view.prefix_items,
|
|
184
185
|
items: view.items,
|
|
185
186
|
contains: view.contains,
|
|
@@ -194,6 +195,7 @@ impl RbCanonicalSchema {
|
|
|
194
195
|
properties: view.properties,
|
|
195
196
|
pattern_properties: view.pattern_properties,
|
|
196
197
|
additional_properties: view.additional_properties,
|
|
198
|
+
violations: view.violations,
|
|
197
199
|
})
|
|
198
200
|
.as_value(),
|
|
199
201
|
CanonicalView::Not(schema) => ruby.obj_wrap(NotView { schema: *schema }).as_value(),
|
|
@@ -641,7 +643,7 @@ impl IntegerView {
|
|
|
641
643
|
pub struct ArrayView {
|
|
642
644
|
min_items: Option<serde_json::Number>,
|
|
643
645
|
max_items: Option<serde_json::Number>,
|
|
644
|
-
|
|
646
|
+
distinctness: &'static str,
|
|
645
647
|
prefix_items: Vec<CanonicalSchema>,
|
|
646
648
|
items: Option<CanonicalSchema>,
|
|
647
649
|
contains: Vec<CoreContainsView>,
|
|
@@ -658,8 +660,8 @@ impl ArrayView {
|
|
|
658
660
|
bound_to_ruby(ruby, rb_self.max_items.as_ref())
|
|
659
661
|
}
|
|
660
662
|
|
|
661
|
-
fn
|
|
662
|
-
ruby.
|
|
663
|
+
fn distinctness(ruby: &Ruby, rb_self: &Self) -> Value {
|
|
664
|
+
ruby.sym_new(rb_self.distinctness).as_value()
|
|
663
665
|
}
|
|
664
666
|
|
|
665
667
|
fn prefix_items(ruby: &Ruby, rb_self: &Self) -> Result<Value, Error> {
|
|
@@ -696,10 +698,10 @@ impl ArrayView {
|
|
|
696
698
|
|
|
697
699
|
fn inspect(ruby: &Ruby, rb_self: &Self) -> Result<String, Error> {
|
|
698
700
|
Ok(format!(
|
|
699
|
-
"#<JSONSchema::Canonical::ArrayView min_items={} max_items={}
|
|
701
|
+
"#<JSONSchema::Canonical::ArrayView min_items={} max_items={} distinctness={} prefix_items={} items={} contains={}>",
|
|
700
702
|
Self::min_items(ruby, rb_self)?.inspect(),
|
|
701
703
|
Self::max_items(ruby, rb_self)?.inspect(),
|
|
702
|
-
Self::
|
|
704
|
+
Self::distinctness(ruby, rb_self).inspect(),
|
|
703
705
|
Self::prefix_items(ruby, rb_self)?.inspect(),
|
|
704
706
|
Self::items(ruby, rb_self).inspect(),
|
|
705
707
|
Self::contains(ruby, rb_self)?.inspect()
|
|
@@ -711,8 +713,8 @@ impl ArrayView {
|
|
|
711
713
|
hash.aset(ruby.sym_new("min_items"), Self::min_items(ruby, rb_self)?)?;
|
|
712
714
|
hash.aset(ruby.sym_new("max_items"), Self::max_items(ruby, rb_self)?)?;
|
|
713
715
|
hash.aset(
|
|
714
|
-
ruby.sym_new("
|
|
715
|
-
Self::
|
|
716
|
+
ruby.sym_new("distinctness"),
|
|
717
|
+
Self::distinctness(ruby, rb_self),
|
|
716
718
|
)?;
|
|
717
719
|
hash.aset(
|
|
718
720
|
ruby.sym_new("prefix_items"),
|
|
@@ -783,6 +785,116 @@ impl ContainsView {
|
|
|
783
785
|
}
|
|
784
786
|
}
|
|
785
787
|
|
|
788
|
+
// The violation list needs the same lazy Ruby-object conversion `ContainsView::from_core` does,
|
|
789
|
+
// so this stays a free function rather than a method on either violation view class.
|
|
790
|
+
fn object_violation_to_ruby(ruby: &Ruby, violation: &CoreObjectViolationView) -> Value {
|
|
791
|
+
match violation {
|
|
792
|
+
CoreObjectViolationView::NameFails(schema) => ruby
|
|
793
|
+
.obj_wrap(NameFailsView {
|
|
794
|
+
schema: schema.clone(),
|
|
795
|
+
})
|
|
796
|
+
.as_value(),
|
|
797
|
+
CoreObjectViolationView::UndeclaredValueFails {
|
|
798
|
+
names,
|
|
799
|
+
patterns,
|
|
800
|
+
additional,
|
|
801
|
+
} => ruby
|
|
802
|
+
.obj_wrap(UndeclaredValueFailsView {
|
|
803
|
+
names: names.clone(),
|
|
804
|
+
patterns: patterns.clone(),
|
|
805
|
+
additional: additional.clone(),
|
|
806
|
+
})
|
|
807
|
+
.as_value(),
|
|
808
|
+
}
|
|
809
|
+
}
|
|
810
|
+
|
|
811
|
+
/// Some key's name fails the schema.
|
|
812
|
+
#[derive(magnus::TypedData)]
|
|
813
|
+
#[magnus(class = "JSONSchema::Canonical::NameFailsView", free_immediately)]
|
|
814
|
+
pub struct NameFailsView {
|
|
815
|
+
schema: CanonicalSchema,
|
|
816
|
+
}
|
|
817
|
+
|
|
818
|
+
impl DataTypeFunctions for NameFailsView {}
|
|
819
|
+
|
|
820
|
+
impl NameFailsView {
|
|
821
|
+
fn schema(ruby: &Ruby, rb_self: &Self) -> Value {
|
|
822
|
+
ruby.obj_wrap(RbCanonicalSchema {
|
|
823
|
+
inner: rb_self.schema.clone(),
|
|
824
|
+
})
|
|
825
|
+
.as_value()
|
|
826
|
+
}
|
|
827
|
+
|
|
828
|
+
fn inspect(ruby: &Ruby, rb_self: &Self) -> String {
|
|
829
|
+
format!(
|
|
830
|
+
"#<JSONSchema::Canonical::NameFailsView schema={}>",
|
|
831
|
+
Self::schema(ruby, rb_self).inspect()
|
|
832
|
+
)
|
|
833
|
+
}
|
|
834
|
+
|
|
835
|
+
fn deconstruct_keys(ruby: &Ruby, rb_self: &Self, _keys: Value) -> Result<RHash, Error> {
|
|
836
|
+
let hash = ruby.hash_new();
|
|
837
|
+
hash.aset(ruby.sym_new("schema"), Self::schema(ruby, rb_self))?;
|
|
838
|
+
Ok(hash)
|
|
839
|
+
}
|
|
840
|
+
}
|
|
841
|
+
|
|
842
|
+
/// Some key outside `names` and matching none of `patterns` has a value failing `additional`.
|
|
843
|
+
#[derive(magnus::TypedData)]
|
|
844
|
+
#[magnus(
|
|
845
|
+
class = "JSONSchema::Canonical::UndeclaredValueFailsView",
|
|
846
|
+
free_immediately
|
|
847
|
+
)]
|
|
848
|
+
pub struct UndeclaredValueFailsView {
|
|
849
|
+
names: Vec<String>,
|
|
850
|
+
patterns: Vec<String>,
|
|
851
|
+
additional: CanonicalSchema,
|
|
852
|
+
}
|
|
853
|
+
|
|
854
|
+
impl DataTypeFunctions for UndeclaredValueFailsView {}
|
|
855
|
+
|
|
856
|
+
impl UndeclaredValueFailsView {
|
|
857
|
+
fn names(ruby: &Ruby, rb_self: &Self) -> Result<Value, Error> {
|
|
858
|
+
let array = ruby.ary_new_capa(rb_self.names.len());
|
|
859
|
+
for name in &rb_self.names {
|
|
860
|
+
array.push(ruby.str_new(name))?;
|
|
861
|
+
}
|
|
862
|
+
Ok(array.as_value())
|
|
863
|
+
}
|
|
864
|
+
|
|
865
|
+
fn patterns(ruby: &Ruby, rb_self: &Self) -> Result<Value, Error> {
|
|
866
|
+
let array = ruby.ary_new_capa(rb_self.patterns.len());
|
|
867
|
+
for pattern in &rb_self.patterns {
|
|
868
|
+
array.push(ruby.str_new(pattern))?;
|
|
869
|
+
}
|
|
870
|
+
Ok(array.as_value())
|
|
871
|
+
}
|
|
872
|
+
|
|
873
|
+
fn additional(ruby: &Ruby, rb_self: &Self) -> Value {
|
|
874
|
+
ruby.obj_wrap(RbCanonicalSchema {
|
|
875
|
+
inner: rb_self.additional.clone(),
|
|
876
|
+
})
|
|
877
|
+
.as_value()
|
|
878
|
+
}
|
|
879
|
+
|
|
880
|
+
fn inspect(ruby: &Ruby, rb_self: &Self) -> Result<String, Error> {
|
|
881
|
+
Ok(format!(
|
|
882
|
+
"#<JSONSchema::Canonical::UndeclaredValueFailsView names={} patterns={} additional={}>",
|
|
883
|
+
Self::names(ruby, rb_self)?.inspect(),
|
|
884
|
+
Self::patterns(ruby, rb_self)?.inspect(),
|
|
885
|
+
Self::additional(ruby, rb_self).inspect()
|
|
886
|
+
))
|
|
887
|
+
}
|
|
888
|
+
|
|
889
|
+
fn deconstruct_keys(ruby: &Ruby, rb_self: &Self, _keys: Value) -> Result<RHash, Error> {
|
|
890
|
+
let hash = ruby.hash_new();
|
|
891
|
+
hash.aset(ruby.sym_new("names"), Self::names(ruby, rb_self)?)?;
|
|
892
|
+
hash.aset(ruby.sym_new("patterns"), Self::patterns(ruby, rb_self)?)?;
|
|
893
|
+
hash.aset(ruby.sym_new("additional"), Self::additional(ruby, rb_self))?;
|
|
894
|
+
Ok(hash)
|
|
895
|
+
}
|
|
896
|
+
}
|
|
897
|
+
|
|
786
898
|
/// An object value's constraints.
|
|
787
899
|
#[derive(magnus::TypedData)]
|
|
788
900
|
#[magnus(class = "JSONSchema::Canonical::ObjectView", free_immediately)]
|
|
@@ -794,6 +906,7 @@ pub struct ObjectView {
|
|
|
794
906
|
properties: std::collections::BTreeMap<String, CanonicalSchema>,
|
|
795
907
|
pattern_properties: std::collections::BTreeMap<String, CanonicalSchema>,
|
|
796
908
|
additional_properties: Option<CanonicalSchema>,
|
|
909
|
+
violations: Vec<CoreObjectViolationView>,
|
|
797
910
|
}
|
|
798
911
|
|
|
799
912
|
impl DataTypeFunctions for ObjectView {}
|
|
@@ -859,6 +972,14 @@ impl ObjectView {
|
|
|
859
972
|
}
|
|
860
973
|
}
|
|
861
974
|
|
|
975
|
+
fn violations(ruby: &Ruby, rb_self: &Self) -> Result<Value, Error> {
|
|
976
|
+
let array = ruby.ary_new_capa(rb_self.violations.len());
|
|
977
|
+
for violation in &rb_self.violations {
|
|
978
|
+
array.push(object_violation_to_ruby(ruby, violation))?;
|
|
979
|
+
}
|
|
980
|
+
Ok(array.as_value())
|
|
981
|
+
}
|
|
982
|
+
|
|
862
983
|
fn inspect(ruby: &Ruby, rb_self: &Self) -> Result<String, Error> {
|
|
863
984
|
Ok(format!(
|
|
864
985
|
"#<JSONSchema::Canonical::ObjectView min_properties={} max_properties={} required={} property_names={} properties={} pattern_properties={}>",
|
|
@@ -895,6 +1016,7 @@ impl ObjectView {
|
|
|
895
1016
|
ruby.sym_new("additional_properties"),
|
|
896
1017
|
Self::additional_properties(ruby, rb_self),
|
|
897
1018
|
)?;
|
|
1019
|
+
hash.aset(ruby.sym_new("violations"), Self::violations(ruby, rb_self)?)?;
|
|
898
1020
|
Ok(hash)
|
|
899
1021
|
}
|
|
900
1022
|
}
|
|
@@ -1299,7 +1421,7 @@ pub(crate) fn init_canonical(ruby: &Ruby, module: &RModule) -> Result<(), Error>
|
|
|
1299
1421
|
let array_view = canonical_module.define_class("ArrayView", ruby.class_object())?;
|
|
1300
1422
|
array_view.define_method("min_items", method!(ArrayView::min_items, 0))?;
|
|
1301
1423
|
array_view.define_method("max_items", method!(ArrayView::max_items, 0))?;
|
|
1302
|
-
array_view.define_method("
|
|
1424
|
+
array_view.define_method("distinctness", method!(ArrayView::distinctness, 0))?;
|
|
1303
1425
|
array_view.define_method("prefix_items", method!(ArrayView::prefix_items, 0))?;
|
|
1304
1426
|
array_view.define_method("items", method!(ArrayView::items, 0))?;
|
|
1305
1427
|
array_view.define_method("contains", method!(ArrayView::contains, 0))?;
|
|
@@ -1315,6 +1437,31 @@ pub(crate) fn init_canonical(ruby: &Ruby, module: &RModule) -> Result<(), Error>
|
|
|
1315
1437
|
method!(ContainsView::deconstruct_keys, 1),
|
|
1316
1438
|
)?;
|
|
1317
1439
|
|
|
1440
|
+
let name_fails_view = canonical_module.define_class("NameFailsView", ruby.class_object())?;
|
|
1441
|
+
name_fails_view.define_method("schema", method!(NameFailsView::schema, 0))?;
|
|
1442
|
+
name_fails_view.define_method("inspect", method!(NameFailsView::inspect, 0))?;
|
|
1443
|
+
name_fails_view.define_method(
|
|
1444
|
+
"deconstruct_keys",
|
|
1445
|
+
method!(NameFailsView::deconstruct_keys, 1),
|
|
1446
|
+
)?;
|
|
1447
|
+
|
|
1448
|
+
let undeclared_value_fails_view =
|
|
1449
|
+
canonical_module.define_class("UndeclaredValueFailsView", ruby.class_object())?;
|
|
1450
|
+
undeclared_value_fails_view
|
|
1451
|
+
.define_method("names", method!(UndeclaredValueFailsView::names, 0))?;
|
|
1452
|
+
undeclared_value_fails_view
|
|
1453
|
+
.define_method("patterns", method!(UndeclaredValueFailsView::patterns, 0))?;
|
|
1454
|
+
undeclared_value_fails_view.define_method(
|
|
1455
|
+
"additional",
|
|
1456
|
+
method!(UndeclaredValueFailsView::additional, 0),
|
|
1457
|
+
)?;
|
|
1458
|
+
undeclared_value_fails_view
|
|
1459
|
+
.define_method("inspect", method!(UndeclaredValueFailsView::inspect, 0))?;
|
|
1460
|
+
undeclared_value_fails_view.define_method(
|
|
1461
|
+
"deconstruct_keys",
|
|
1462
|
+
method!(UndeclaredValueFailsView::deconstruct_keys, 1),
|
|
1463
|
+
)?;
|
|
1464
|
+
|
|
1318
1465
|
let object_view = canonical_module.define_class("ObjectView", ruby.class_object())?;
|
|
1319
1466
|
object_view.define_method("min_properties", method!(ObjectView::min_properties, 0))?;
|
|
1320
1467
|
object_view.define_method("max_properties", method!(ObjectView::max_properties, 0))?;
|
|
@@ -1329,6 +1476,7 @@ pub(crate) fn init_canonical(ruby: &Ruby, module: &RModule) -> Result<(), Error>
|
|
|
1329
1476
|
"additional_properties",
|
|
1330
1477
|
method!(ObjectView::additional_properties, 0),
|
|
1331
1478
|
)?;
|
|
1479
|
+
object_view.define_method("violations", method!(ObjectView::violations, 0))?;
|
|
1332
1480
|
object_view.define_method("inspect", method!(ObjectView::inspect, 0))?;
|
|
1333
1481
|
object_view.define_method("deconstruct_keys", method!(ObjectView::deconstruct_keys, 1))?;
|
|
1334
1482
|
|