From 6046dce57aef482ae4875d83439007931408e182 Mon Sep 17 00:00:00 2001 From: Dmitry Dygalo Date: Wed, 23 Oct 2024 19:26:30 +0200 Subject: [PATCH] fix: $ref interaction with $recursiveAnchor in Draft 2019-09 Signed-off-by: Dmitry Dygalo --- CHANGELOG.md | 1 + crates/jsonschema-py/CHANGELOG.md | 1 + crates/jsonschema/src/compiler.rs | 6 +----- crates/jsonschema/tests/suite.rs | 1 - 4 files changed, 3 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index feaff803..a4b09854 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,7 @@ ### Fixed - Infinite recursion in some cases. [#146](https://github.com/Stranger6667/jsonschema-rs/issues/146) +- `$ref` interaction with `$recursiveAnchor` in Draft 2019-09. ## [0.24.1] - 2024-10-21 diff --git a/crates/jsonschema-py/CHANGELOG.md b/crates/jsonschema-py/CHANGELOG.md index 3bf8e30d..0b4ed4a6 100644 --- a/crates/jsonschema-py/CHANGELOG.md +++ b/crates/jsonschema-py/CHANGELOG.md @@ -5,6 +5,7 @@ ### Fixed - Infinite recursion in some cases. [#146](https://github.com/Stranger6667/jsonschema-rs/issues/146) +- `$ref` interaction with `$recursiveAnchor` in Draft 2019-09. ## [0.24.1] - 2024-10-22 diff --git a/crates/jsonschema/src/compiler.rs b/crates/jsonschema/src/compiler.rs index 495d09ff..e011ee71 100644 --- a/crates/jsonschema/src/compiler.rs +++ b/crates/jsonschema/src/compiler.rs @@ -207,11 +207,7 @@ impl<'a> Context<'a> { reference: &str, is_recursive: bool, ) -> Result, ValidationError<'static>> { - let resolved = if reference == "#" { - // Known & simple recursive reference - // It may also use some additional logic from the `$recursiveAnchor` keyword - self.resolver.lookup_recursive_ref()? - } else if self.is_circular_reference(reference)? { + let resolved = if self.is_circular_reference(reference)? { // Otherwise we need to manually check whether this location has already been explored self.resolver.lookup(reference)? } else { diff --git a/crates/jsonschema/tests/suite.rs b/crates/jsonschema/tests/suite.rs index ab77d7af..02375d54 100644 --- a/crates/jsonschema/tests/suite.rs +++ b/crates/jsonschema/tests/suite.rs @@ -16,7 +16,6 @@ mod tests { xfail = [ "draft4::optional::bignum::integer::a_bignum_is_an_integer", "draft4::optional::bignum::integer::a_negative_bignum_is_an_integer", - "draft2019-09::r#ref::ref_with_recursive_anchor::extra_items_allowed_for_inner_arrays", "draft2019-09::unevaluated_properties::unevaluated_properties_with_recursive_ref::with_no_unevaluated_properties_10", "draft2020-12::unevaluated_properties::unevaluated_properties_with_dynamic_ref::with_no_unevaluated_properties_21", ]