Skip to content

Commit

Permalink
Do not frame relative anchor URIs for schemas with identifiers (#455)
Browse files Browse the repository at this point in the history
Signed-off-by: Juan Cruz Viotti <[email protected]>
  • Loading branch information
jviotti authored Jan 18, 2024
1 parent c4f09f2 commit 002d645
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 23 deletions.
5 changes: 0 additions & 5 deletions src/jsonschema/reference.cc
Original file line number Diff line number Diff line change
Expand Up @@ -191,11 +191,6 @@ auto sourcemeta::jsontoolkit::frame(
if (type == sourcemeta::jsontoolkit::AnchorType::Static) {
frame.store(absolute_anchor_uri, ReferenceType::Static, root_id,
base_string, pointer, effective_dialects.front());

if (root_id.has_value() && root_id.value() == base_string) {
frame.store(relative_anchor_uri, ReferenceType::Static, root_id,
"", pointer, effective_dialects.front());
}
}

is_first = false;
Expand Down
12 changes: 3 additions & 9 deletions test/jsonschema/jsonschema_frame_2019_09_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ TEST(JSONSchema_frame_2019_09, one_level_applicators_with_identifiers) {
sourcemeta::jsontoolkit::official_resolver)
.wait();

EXPECT_EQ(frame.size(), 15);
EXPECT_EQ(frame.size(), 14);

EXPECT_FRAME_STATIC_2019_09(frame, "https://www.sourcemeta.com/test/qux",
"https://www.sourcemeta.com/test/qux", "");
Expand All @@ -121,8 +121,6 @@ TEST(JSONSchema_frame_2019_09, one_level_applicators_with_identifiers) {
EXPECT_FRAME_STATIC_2019_09(frame, "https://www.sourcemeta.com/test/qux#test",
"https://www.sourcemeta.com/test/qux",
"/properties/foo");
EXPECT_FRAME_STATIC_2019_09(
frame, "#test", "https://www.sourcemeta.com/test/qux", "/properties/foo");

// JSON Pointers

Expand Down Expand Up @@ -447,7 +445,7 @@ TEST(JSONSchema_frame_2019_09, anchor_top_level) {
sourcemeta::jsontoolkit::official_resolver)
.wait();

EXPECT_EQ(frame.size(), 6);
EXPECT_EQ(frame.size(), 5);

EXPECT_FRAME_STATIC_2019_09(frame, "https://www.sourcemeta.com/schema",
"https://www.sourcemeta.com/schema", "");
Expand All @@ -464,8 +462,6 @@ TEST(JSONSchema_frame_2019_09, anchor_top_level) {

EXPECT_FRAME_STATIC_2019_09(frame, "https://www.sourcemeta.com/schema#foo",
"https://www.sourcemeta.com/schema", "");
EXPECT_FRAME_STATIC_2019_09(frame, "#foo",
"https://www.sourcemeta.com/schema", "");

// References

Expand Down Expand Up @@ -501,7 +497,7 @@ TEST(JSONSchema_frame_2019_09, explicit_argument_id_different) {
"https://www.example.com")
.wait();

EXPECT_EQ(frame.size(), 39);
EXPECT_EQ(frame.size(), 38);

EXPECT_FRAME_STATIC_2019_09(frame, "https://www.sourcemeta.com/schema",
"https://www.sourcemeta.com/schema", "");
Expand Down Expand Up @@ -532,8 +528,6 @@ TEST(JSONSchema_frame_2019_09, explicit_argument_id_different) {
EXPECT_FRAME_STATIC_2019_09(frame, "https://www.test.com#baz",
"https://www.sourcemeta.com/schema",
"/properties/two");
EXPECT_FRAME_STATIC_2019_09(frame, "#foo",
"https://www.sourcemeta.com/schema", "/items");

// JSON Pointers

Expand Down
12 changes: 3 additions & 9 deletions test/jsonschema/jsonschema_frame_2020_12_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ TEST(JSONSchema_frame_2020_12, one_level_applicators_with_identifiers) {
sourcemeta::jsontoolkit::official_resolver)
.wait();

EXPECT_EQ(frame.size(), 15);
EXPECT_EQ(frame.size(), 14);
EXPECT_FRAME_STATIC_2020_12(frame, "https://www.sourcemeta.com/test/qux",
"https://www.sourcemeta.com/test/qux", "");
EXPECT_FRAME_STATIC_2020_12(frame, "https://www.sourcemeta.com/foo",
Expand All @@ -120,8 +120,6 @@ TEST(JSONSchema_frame_2020_12, one_level_applicators_with_identifiers) {
EXPECT_FRAME_STATIC_2020_12(frame, "https://www.sourcemeta.com/test/qux#test",
"https://www.sourcemeta.com/test/qux",
"/properties/foo");
EXPECT_FRAME_STATIC_2020_12(
frame, "#test", "https://www.sourcemeta.com/test/qux", "/properties/foo");

// JSON Pointers

Expand Down Expand Up @@ -440,7 +438,7 @@ TEST(JSONSchema_frame_2020_12, anchor_top_level) {
sourcemeta::jsontoolkit::official_resolver)
.wait();

EXPECT_EQ(frame.size(), 6);
EXPECT_EQ(frame.size(), 5);

EXPECT_FRAME_STATIC_2020_12(frame, "https://www.sourcemeta.com/schema",
"https://www.sourcemeta.com/schema", "");
Expand All @@ -457,8 +455,6 @@ TEST(JSONSchema_frame_2020_12, anchor_top_level) {

EXPECT_FRAME_STATIC_2020_12(frame, "https://www.sourcemeta.com/schema#foo",
"https://www.sourcemeta.com/schema", "");
EXPECT_FRAME_STATIC_2020_12(frame, "#foo",
"https://www.sourcemeta.com/schema", "");

// References

Expand Down Expand Up @@ -494,7 +490,7 @@ TEST(JSONSchema_frame_2020_12, explicit_argument_id_different) {
"https://www.example.com")
.wait();

EXPECT_EQ(frame.size(), 39);
EXPECT_EQ(frame.size(), 38);

EXPECT_FRAME_STATIC_2020_12(frame, "https://www.sourcemeta.com/schema",
"https://www.sourcemeta.com/schema", "");
Expand Down Expand Up @@ -525,8 +521,6 @@ TEST(JSONSchema_frame_2020_12, explicit_argument_id_different) {
EXPECT_FRAME_STATIC_2020_12(frame, "https://www.test.com#baz",
"https://www.sourcemeta.com/schema",
"/properties/two");
EXPECT_FRAME_STATIC_2020_12(frame, "#foo",
"https://www.sourcemeta.com/schema", "/items");

// JSON Pointers

Expand Down

0 comments on commit 002d645

Please sign in to comment.