Skip to content

Commit 4896ec3

Browse files
committed
Do not inline recursive references at all
1 parent 6323e9a commit 4896ec3

File tree

1 file changed

+5
-13
lines changed

1 file changed

+5
-13
lines changed

tests/test_canonicalise.py

+5-13
Original file line numberDiff line numberDiff line change
@@ -542,12 +542,12 @@ def test_validators_use_proper_draft():
542542
(ROOT_REFERENCE, ROOT_REFERENCE),
543543
(NESTED, NESTED),
544544
(NESTED_WITH_ID, NESTED_WITH_ID),
545-
# "foo" content should be inlined as is, because "#" is recursive (special case)
545+
# "foo" content should not be inlined, because "#" is recursive (special case)
546546
(
547547
{"foo": {"$ref": "#"}, "not": {"$ref": "#foo"}},
548-
{"foo": {"$ref": "#"}, "not": {"$ref": "#"}},
548+
{"foo": {"$ref": "#"}, "not": {"$ref": "#foo"}},
549549
),
550-
# "foo" content should be inlined as is, because it points to itself
550+
# "foo" content should not be inlined, because it points to itself
551551
(
552552
SELF_REFERENTIAL,
553553
SELF_REFERENTIAL,
@@ -558,15 +558,14 @@ def test_validators_use_proper_draft():
558558
# 1. We start from resolving "$ref" in "not"
559559
# 2. at this point we don't know this path is recursive, so we follow to "foo"
560560
# 3. inside "foo" we found a reference to "foo", which means it is recursive
561-
{"foo": {"not": {"$ref": "#foo"}}, "not": {"not": {"$ref": "#foo"}}},
561+
{"foo": {"not": {"$ref": "#foo"}}, "not": {"$ref": "#foo"}},
562562
),
563563
# Circular reference between two schemas
564564
(
565565
{"foo": {"$ref": "#bar"}, "bar": {"$ref": "#foo"}, "not": {"$ref": "#foo"}},
566566
# 1. We start in "not" and follow to "foo"
567567
# 2. In "foo" we follow to "bar"
568568
# 3. Here we see a reference to previously seen scope, which means it is a recursive path
569-
# We take the schema where we stop and inline it to the starting point (therefore it is `{"$ref": "#foo"}`)
570569
{"foo": {"$ref": "#bar"}, "bar": {"$ref": "#foo"}, "not": {"$ref": "#foo"}},
571570
),
572571
),
@@ -637,14 +636,7 @@ def test_skip_recursive_references_simple_schemas(schema, expected):
637636
"properties": {"foo": {"$ref": "#/definitions/foo"}},
638637
},
639638
{
640-
"properties": {
641-
"foo": {
642-
"properties": {
643-
"bar": {"$ref": "#/definitions/foo"},
644-
"baz": {"$ref": "#/definitions/foo"},
645-
}
646-
}
647-
},
639+
"properties": {"foo": {"$ref": "#/definitions/foo"}},
648640
},
649641
),
650642
),

0 commit comments

Comments
 (0)