Skip to content

Commit ca56d80

Browse files
authored
Resolve modern meta-schemas also with an empty fragment (#1816)
Signed-off-by: Juan Cruz Viotti <jv@jviotti.com>
1 parent d354e8a commit ca56d80

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed

src/core/jsonschema/official_resolver.in.cc

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,11 @@ auto sourcemeta::core::schema_official_resolver(std::string_view identifier)
5252
return sourcemeta::core::parse_json(
5353
R"EOF(@METASCHEMA_JSONSCHEMA_2020_12_OUTPUT@)EOF");
5454

55+
// Just for compatibility given that this is such a common issue
56+
} else if (identifier == "https://json-schema.org/draft/2020-12/schema#") {
57+
return sourcemeta::core::parse_json(
58+
R"EOF(@METASCHEMA_JSONSCHEMA_2020_12@)EOF");
59+
5560
// JSON Schema 2019-09
5661
} else if (identifier == "https://json-schema.org/draft/2019-09/schema") {
5762
return sourcemeta::core::parse_json(
@@ -98,6 +103,11 @@ auto sourcemeta::core::schema_official_resolver(std::string_view identifier)
98103
return sourcemeta::core::parse_json(
99104
R"EOF(@METASCHEMA_HYPERSCHEMA_2019_09_OUTPUT@)EOF");
100105

106+
// Just for compatibility given that this is such a common issue
107+
} else if (identifier == "https://json-schema.org/draft/2019-09/schema#") {
108+
return sourcemeta::core::parse_json(
109+
R"EOF(@METASCHEMA_JSONSCHEMA_2019_09@)EOF");
110+
101111
// JSON Schema Draft7
102112
} else if (identifier == "http://json-schema.org/draft-07/schema#" ||
103113
identifier == "http://json-schema.org/draft-07/schema") {

test/jsonschema/jsonschema_official_resolver_test.cc

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,9 @@ TEST(JSONSchema_official_resolver, jsonschema_2020_12) {
3131
EXPECT_SCHEMA("https://json-schema.org/draft/2020-12/meta/validation");
3232
EXPECT_SCHEMA("https://json-schema.org/draft/2020-12/links");
3333
EXPECT_SCHEMA("https://json-schema.org/draft/2020-12/output/schema");
34+
35+
// Just because a lot of people get this wrong
36+
EXPECT_SCHEMA("https://json-schema.org/draft/2020-12/schema#");
3437
}
3538

3639
TEST(JSONSchema_official_resolver, jsonschema_2019_09) {
@@ -45,6 +48,9 @@ TEST(JSONSchema_official_resolver, jsonschema_2019_09) {
4548
EXPECT_SCHEMA("https://json-schema.org/draft/2019-09/output/schema");
4649
EXPECT_SCHEMA("https://json-schema.org/draft/2019-09/links");
4750
EXPECT_SCHEMA("https://json-schema.org/draft/2019-09/output/hyper-schema");
51+
52+
// Just because a lot of people get this wrong
53+
EXPECT_SCHEMA("https://json-schema.org/draft/2019-09/schema#");
4854
}
4955

5056
TEST(JSONSchema_official_resolver, jsonschema_draft7) {

0 commit comments

Comments
 (0)