Skip to content

Commit

Permalink
[WIP] Support relative base URIs
Browse files Browse the repository at this point in the history
Fixes: #960
See: sourcemeta/jsonschema#185
Signed-off-by: Juan Cruz Viotti <[email protected]>
  • Loading branch information
jviotti committed Nov 4, 2024
1 parent 3b644bf commit 56fc183
Showing 1 changed file with 50 additions and 0 deletions.
50 changes: 50 additions & 0 deletions test/jsonschema/jsonschema_bundle_draft4_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -585,3 +585,53 @@ TEST(JSONSchema_bundle_draft4, metaschema_without_id) {

EXPECT_EQ(document, expected);
}

TEST(JSONSchema_bundle_draft4, relative_base_uri_without_ref) {
sourcemeta::jsontoolkit::JSON document =
sourcemeta::jsontoolkit::parse(R"JSON({
"$schema": "http://json-schema.org/draft-04/schema#",
"id": "foo"
})JSON");

sourcemeta::jsontoolkit::bundle(
document, sourcemeta::jsontoolkit::default_schema_walker, test_resolver);

const sourcemeta::jsontoolkit::JSON expected =
sourcemeta::jsontoolkit::parse(R"JSON({
"$schema": "http://json-schema.org/draft-04/schema#",
"id": "foo"
})JSON");

EXPECT_EQ(document, expected);
}

TEST(JSONSchema_bundle_draft4, relative_base_uri_with_ref) {
sourcemeta::jsontoolkit::JSON document =
sourcemeta::jsontoolkit::parse(R"JSON({
"$schema": "http://json-schema.org/draft-04/schema#",
"id": "common",
"allOf": [ { "$ref": "#reference" } ],
"definitions": {
"reference": {
"id": "#reference"
}
}
})JSON");

sourcemeta::jsontoolkit::bundle(
document, sourcemeta::jsontoolkit::default_schema_walker, test_resolver);

const sourcemeta::jsontoolkit::JSON expected =
sourcemeta::jsontoolkit::parse(R"JSON({
"$schema": "http://json-schema.org/draft-04/schema#",
"id": "common",
"allOf": [ { "$ref": "#reference" } ],
"definitions": {
"reference": {
"id": "#reference"
}
}
})JSON");

EXPECT_EQ(document, expected);
}

0 comments on commit 56fc183

Please sign in to comment.