Skip to content

Commit

Permalink
Support compiling HyperSchema
Browse files Browse the repository at this point in the history
Signed-off-by: Juan Cruz Viotti <[email protected]>
  • Loading branch information
jviotti committed Jan 13, 2025
1 parent c5c65a1 commit 4dbcdd0
Show file tree
Hide file tree
Showing 7 changed files with 64 additions and 4 deletions.
2 changes: 1 addition & 1 deletion DEPENDENCIES
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
vendorpull https://github.com/sourcemeta/vendorpull dea311b5bfb53b6926a4140267959ae334d3ecf4
noa https://github.com/sourcemeta/noa 99f8b42d5f1a8b0f9b3c024f5957dc399bc0262f
jsontoolkit https://github.com/sourcemeta/jsontoolkit 4b04d73bfcc26c51b3fff49f373236ceb0456de3
jsontoolkit https://github.com/sourcemeta/jsontoolkit 155f7dfe71259a3bd18cf51155ef7d63540df3f5
googletest https://github.com/google/googletest a7f443b80b105f940225332ed3c31f2790092f47
googlebenchmark https://github.com/google/benchmark 378fe693a1ef51500db21b11ff05a8018c5f0e55
jsonschema-test-suite https://github.com/json-schema-org/JSON-Schema-Test-Suite c2badb1298a8698f86dadf1aea7b44b3a894e5ac
2 changes: 2 additions & 0 deletions src/compiler/default_compiler.cc
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ auto sourcemeta::blaze::default_schema_compiler(
-> sourcemeta::blaze::Instructions {
assert(!dynamic_context.keyword.empty());

// TODO: Support HyperSchema in Draft 7 and earlier
static std::set<std::string> SUPPORTED_VOCABULARIES{
"https://json-schema.org/draft/2020-12/vocab/core",
"https://json-schema.org/draft/2020-12/vocab/applicator",
Expand All @@ -32,6 +33,7 @@ auto sourcemeta::blaze::default_schema_compiler(
"https://json-schema.org/draft/2019-09/vocab/meta-data",
"https://json-schema.org/draft/2019-09/vocab/format",
"https://json-schema.org/draft/2019-09/vocab/content",
"https://json-schema.org/draft/2019-09/vocab/hyper-schema",
"http://json-schema.org/draft-07/schema#",
"http://json-schema.org/draft-06/schema#",
"http://json-schema.org/draft-04/schema#"};
Expand Down
8 changes: 8 additions & 0 deletions test/evaluator/evaluator_2019_09_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,14 @@ TEST(Evaluator_2019_09, metaschema_1) {
EVALUATE_WITH_TRACE_FAST_SUCCESS(metaschema.value(), instance, 54);
}

TEST(Evaluator_2019_09, metaschema_hyper_1) {
const auto metaschema{sourcemeta::jsontoolkit::official_resolver(
"https://json-schema.org/draft/2019-09/hyper-schema")};
EXPECT_TRUE(metaschema.has_value());
const auto instance{sourcemeta::jsontoolkit::parse(R"JSON({})JSON")};
EVALUATE_WITH_TRACE_FAST_SUCCESS(metaschema.value(), instance, 30);
}

TEST(Evaluator_2019_09, properties_1) {
const sourcemeta::jsontoolkit::JSON schema{
sourcemeta::jsontoolkit::parse(R"JSON({
Expand Down
8 changes: 8 additions & 0 deletions test/evaluator/evaluator_2020_12_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,14 @@ TEST(Evaluator_2020_12, unknown_1) {
EVALUATE_WITH_TRACE_FAST_SUCCESS(schema, instance, 0);
}

TEST(Evaluator_2020_12, metaschema_hyper_1) {
const auto metaschema{sourcemeta::jsontoolkit::official_resolver(
"https://json-schema.org/draft/2020-12/hyper-schema")};
EXPECT_TRUE(metaschema.has_value());
const auto instance{sourcemeta::jsontoolkit::parse(R"JSON({})JSON")};
EVALUATE_WITH_TRACE_FAST_SUCCESS(metaschema.value(), instance, 33);
}

TEST(Evaluator_2020_12, unknown_1_exhaustive) {
const sourcemeta::jsontoolkit::JSON schema{
sourcemeta::jsontoolkit::parse(R"JSON({
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 11 additions & 0 deletions vendor/jsontoolkit/src/json/json_value.cc

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 8 additions & 3 deletions vendor/jsontoolkit/src/jsonschema/bundle.cc

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 4dbcdd0

Please sign in to comment.