Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion DEPENDENCIES
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
vendorpull https://github.com/sourcemeta/vendorpull 1dcbac42809cf87cb5b045106b863e17ad84ba02
core https://github.com/sourcemeta/core 376f397db98e72be48d8401e2fbf2ee96f033966
core https://github.com/sourcemeta/core 1c2f2011df7c37543265ad5d89153189b4649013
bootstrap https://github.com/twbs/bootstrap 1a6fdfae6be09b09eaced8f0e442ca6f7680a61e
5 changes: 3 additions & 2 deletions src/compiler/mapper/enum_8_bit.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,9 @@ class Enum8Bit final : public sourcemeta::core::SchemaTransformRule {
return location.dialect == "https://json-schema.org/draft/2020-12/schema" &&
vocabularies.contains(sourcemeta::core::Vocabularies::Known::
JSON_Schema_2020_12_Validation) &&
schema.defines("enum") && schema.at("enum").is_array() &&
!location.pointer.empty() && schema.at("enum").size() > 1 &&
schema.is_object() && schema.defines("enum") &&
schema.at("enum").is_array() && !location.pointer.empty() &&
schema.at("enum").size() > 1 &&
is_byte(schema.at("enum").size() - 1);
}

Expand Down
5 changes: 3 additions & 2 deletions src/compiler/mapper/enum_8_bit_top_level.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,9 @@ class Enum8BitTopLevel final : public sourcemeta::core::SchemaTransformRule {
return location.dialect == "https://json-schema.org/draft/2020-12/schema" &&
vocabularies.contains(sourcemeta::core::Vocabularies::Known::
JSON_Schema_2020_12_Validation) &&
schema.defines("enum") && schema.at("enum").is_array() &&
location.pointer.empty() && schema.at("enum").size() > 1 &&
schema.is_object() && schema.defines("enum") &&
schema.at("enum").is_array() && location.pointer.empty() &&
schema.at("enum").size() > 1 &&
is_byte(schema.at("enum").size() - 1);
}

Expand Down
5 changes: 3 additions & 2 deletions src/compiler/mapper/enum_arbitrary.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,9 @@ class EnumArbitrary final : public sourcemeta::core::SchemaTransformRule {
return location.dialect == "https://json-schema.org/draft/2020-12/schema" &&
vocabularies.contains(sourcemeta::core::Vocabularies::Known::
JSON_Schema_2020_12_Validation) &&
schema.defines("enum") && schema.at("enum").is_array() &&
!location.pointer.empty() && schema.at("enum").size() > 1 &&
schema.is_object() && schema.defines("enum") &&
schema.at("enum").is_array() && !location.pointer.empty() &&
schema.at("enum").size() > 1 &&
!is_byte(schema.at("enum").size() - 1);
}

Expand Down
4 changes: 2 additions & 2 deletions src/compiler/mapper/enum_singleton.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ class EnumSingleton final : public sourcemeta::core::SchemaTransformRule {
return location.dialect == "https://json-schema.org/draft/2020-12/schema" &&
vocabularies.contains(sourcemeta::core::Vocabularies::Known::
JSON_Schema_2020_12_Validation) &&
schema.defines("enum") && schema.at("enum").is_array() &&
schema.at("enum").size() == 1;
schema.is_object() && schema.defines("enum") &&
schema.at("enum").is_array() && schema.at("enum").size() == 1;
}

auto transform(sourcemeta::core::JSON &schema,
Expand Down
2 changes: 1 addition & 1 deletion src/compiler/mapper/integer_bounded_8_bit.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class IntegerBounded8Bit final : public sourcemeta::core::SchemaTransformRule {
return location.dialect == "https://json-schema.org/draft/2020-12/schema" &&
vocabularies.contains(sourcemeta::core::Vocabularies::Known::
JSON_Schema_2020_12_Validation) &&
schema.defines("type") &&
schema.is_object() && schema.defines("type") &&
schema.at("type").to_string() == "integer" &&
schema.defines("minimum") && schema.defines("maximum") &&
is_byte(schema.at("maximum").to_integer() -
Expand Down
2 changes: 1 addition & 1 deletion src/compiler/mapper/integer_bounded_greater_than_8_bit.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class IntegerBoundedGreaterThan8Bit final
return location.dialect == "https://json-schema.org/draft/2020-12/schema" &&
vocabularies.contains(sourcemeta::core::Vocabularies::Known::
JSON_Schema_2020_12_Validation) &&
schema.defines("type") &&
schema.is_object() && schema.defines("type") &&
schema.at("type").to_string() == "integer" &&
schema.defines("minimum") && schema.defines("maximum") &&
!is_byte(schema.at("maximum").to_integer() -
Expand Down
3 changes: 2 additions & 1 deletion src/compiler/mapper/integer_bounded_multiplier_8_bit.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ class IntegerBoundedMultiplier8Bit final
if (location.dialect != "https://json-schema.org/draft/2020-12/schema" ||
!vocabularies.contains(sourcemeta::core::Vocabularies::Known::
JSON_Schema_2020_12_Validation) ||
!schema.defines("type") || schema.at("type").to_string() != "integer" ||
!schema.is_object() || !schema.defines("type") ||
schema.at("type").to_string() != "integer" ||
!schema.defines("minimum") || !schema.at("minimum").is_integer() ||
!schema.defines("maximum") || !schema.at("maximum").is_integer() ||
!schema.defines("multipleOf") ||
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ class IntegerBoundedMultiplierGreaterThan8Bit final
if (location.dialect != "https://json-schema.org/draft/2020-12/schema" ||
!vocabularies.contains(sourcemeta::core::Vocabularies::Known::
JSON_Schema_2020_12_Validation) ||
!schema.defines("type") || schema.at("type").to_string() != "integer" ||
!schema.is_object() || !schema.defines("type") ||
schema.at("type").to_string() != "integer" ||
!schema.defines("minimum") || !schema.at("minimum").is_integer() ||
!schema.defines("maximum") || !schema.at("maximum").is_integer() ||
!schema.defines("multipleOf") ||
Expand Down
2 changes: 1 addition & 1 deletion src/compiler/mapper/integer_lower_bound.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class IntegerLowerBound final : public sourcemeta::core::SchemaTransformRule {
return location.dialect == "https://json-schema.org/draft/2020-12/schema" &&
vocabularies.contains(sourcemeta::core::Vocabularies::Known::
JSON_Schema_2020_12_Validation) &&
schema.defines("type") &&
schema.is_object() && schema.defines("type") &&
schema.at("type").to_string() == "integer" &&
schema.defines("minimum") && !schema.defines("maximum") &&
!schema.defines("multipleOf");
Expand Down
2 changes: 1 addition & 1 deletion src/compiler/mapper/integer_lower_bound_multiplier.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class IntegerLowerBoundMultiplier final
return location.dialect == "https://json-schema.org/draft/2020-12/schema" &&
vocabularies.contains(sourcemeta::core::Vocabularies::Known::
JSON_Schema_2020_12_Validation) &&
schema.defines("type") &&
schema.is_object() && schema.defines("type") &&
schema.at("type").to_string() == "integer" &&
schema.defines("minimum") && !schema.defines("maximum") &&
schema.defines("multipleOf") && schema.at("multipleOf").is_integer();
Expand Down
2 changes: 1 addition & 1 deletion src/compiler/mapper/integer_unbound.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class IntegerUnbound final : public sourcemeta::core::SchemaTransformRule {
return location.dialect == "https://json-schema.org/draft/2020-12/schema" &&
vocabularies.contains(sourcemeta::core::Vocabularies::Known::
JSON_Schema_2020_12_Validation) &&
schema.defines("type") &&
schema.is_object() && schema.defines("type") &&
schema.at("type").to_string() == "integer" &&
!schema.defines("minimum") && !schema.defines("maximum") &&
!schema.defines("multipleOf");
Expand Down
2 changes: 1 addition & 1 deletion src/compiler/mapper/integer_unbound_multiplier.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class IntegerUnboundMultiplier final
return location.dialect == "https://json-schema.org/draft/2020-12/schema" &&
vocabularies.contains(sourcemeta::core::Vocabularies::Known::
JSON_Schema_2020_12_Validation) &&
schema.defines("type") &&
schema.is_object() && schema.defines("type") &&
schema.at("type").to_string() == "integer" &&
!schema.defines("minimum") && !schema.defines("maximum") &&
schema.defines("multipleOf") && schema.at("multipleOf").is_integer();
Expand Down
2 changes: 1 addition & 1 deletion src/compiler/mapper/integer_upper_bound.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class IntegerUpperBound final : public sourcemeta::core::SchemaTransformRule {
return location.dialect == "https://json-schema.org/draft/2020-12/schema" &&
vocabularies.contains(sourcemeta::core::Vocabularies::Known::
JSON_Schema_2020_12_Validation) &&
schema.defines("type") &&
schema.is_object() && schema.defines("type") &&
schema.at("type").to_string() == "integer" &&
!schema.defines("minimum") && schema.defines("maximum") &&
!schema.defines("multipleOf");
Expand Down
2 changes: 1 addition & 1 deletion src/compiler/mapper/integer_upper_bound_multiplier.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class IntegerUpperBoundMultiplier final
return location.dialect == "https://json-schema.org/draft/2020-12/schema" &&
vocabularies.contains(sourcemeta::core::Vocabularies::Known::
JSON_Schema_2020_12_Validation) &&
schema.defines("type") &&
schema.is_object() && schema.defines("type") &&
schema.at("type").to_string() == "integer" &&
!schema.defines("minimum") && schema.defines("maximum") &&
schema.defines("multipleOf") && schema.at("multipleOf").is_integer();
Expand Down
3 changes: 2 additions & 1 deletion src/compiler/mapper/number_arbitrary.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ class NumberArbitrary final : public sourcemeta::core::SchemaTransformRule {
return location.dialect == "https://json-schema.org/draft/2020-12/schema" &&
vocabularies.contains(sourcemeta::core::Vocabularies::Known::
JSON_Schema_2020_12_Validation) &&
schema.defines("type") && schema.at("type").to_string() == "number";
schema.is_object() && schema.defines("type") &&
schema.at("type").to_string() == "number";
}

auto transform(sourcemeta::core::JSON &schema,
Expand Down
27 changes: 5 additions & 22 deletions test/compiler/2020_12_canonicalizer_any_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,7 @@ TEST(JSONBinPack_Canonicalizer_Any_2020_12, type_union_anyof_1) {
},
{
"type": "array",
"items": true,
"minItems": 0
}
]
Expand Down Expand Up @@ -172,6 +173,7 @@ TEST(JSONBinPack_Canonicalizer_Any_2020_12, type_union_anyof_2) {
},
{
"type": "array",
"items": true,
"minItems": 0
}
]
Expand Down Expand Up @@ -208,6 +210,7 @@ TEST(JSONBinPack_Canonicalizer_Any_2020_12, type_union_anyof_3) {
},
{
"type": "array",
"items": true,
"minItems": 0
}
]
Expand Down Expand Up @@ -238,6 +241,7 @@ TEST(JSONBinPack_Canonicalizer_Any_2020_12, implicit_type_union_1) {
},
{
"type": "array",
"items": true,
"minItems": 0
},
{
Expand All @@ -261,28 +265,7 @@ TEST(JSONBinPack_Canonicalizer_Any_2020_12, boolean_schema_1) {
sourcemeta::core::schema_resolver,
"https://json-schema.org/draft/2020-12/schema");

const auto expected = sourcemeta::core::parse_json(R"JSON({
"anyOf": [
{ "enum": [ null ] },
{ "enum": [ false, true ] },
{
"type": "object",
"minProperties": 0,
"properties": {}
},
{
"type": "array",
"minItems": 0
},
{
"type": "string",
"minLength": 0
},
{
"type": "number"
}
]
})JSON");
const sourcemeta::core::JSON expected{true};

EXPECT_EQ(schema, expected);
}
Expand Down
7 changes: 7 additions & 0 deletions test/compiler/2020_12_canonicalizer_array_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ TEST(JSONBinPack_Canonicalizer_Array_2020_12, max_contains_without_contains_1) {
const auto expected = sourcemeta::core::parse_json(R"JSON({
"$schema": "https://json-schema.org/draft/2020-12/schema",
"type": "array",
"items": true,
"minItems": 0
})JSON");

Expand All @@ -42,6 +43,7 @@ TEST(JSONBinPack_Canonicalizer_Array_2020_12, max_contains_without_contains_2) {
"minLength": 0
},
"maxContains": 2,
"items": true,
"minItems": 0
})JSON");

Expand All @@ -61,6 +63,7 @@ TEST(JSONBinPack_Canonicalizer_Array_2020_12, min_contains_without_contains_1) {
const auto expected = sourcemeta::core::parse_json(R"JSON({
"$schema": "https://json-schema.org/draft/2020-12/schema",
"type": "array",
"items": true,
"minItems": 0
})JSON");

Expand All @@ -86,6 +89,7 @@ TEST(JSONBinPack_Canonicalizer_Array_2020_12, min_contains_without_contains_2) {
"minLength": 0
},
"minContains": 2,
"items": true,
"minItems": 2
})JSON");

Expand Down Expand Up @@ -113,6 +117,7 @@ TEST(JSONBinPack_Canonicalizer_Array_2020_12, unsatisfiable_max_contains_1) {
},
"maxItems": 2,
"maxContains": 2,
"items": true,
"minItems": 0
})JSON");

Expand All @@ -131,6 +136,7 @@ TEST(JSONBinPack_Canonicalizer_Array_2020_12, implicit_array_lower_bound_1) {
const auto expected = sourcemeta::core::parse_json(R"JSON({
"$schema": "https://json-schema.org/draft/2020-12/schema",
"type": "array",
"items": true,
"minItems": 0
})JSON");

Expand All @@ -152,6 +158,7 @@ TEST(JSONBinPack_Canonicalizer_Array_2020_12, drop_non_array_keywords_1) {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"type": "array",
"maxItems": 4,
"items": true,
"minItems": 0
})JSON");

Expand Down
Loading