@@ -10211,9 +10211,13 @@ TEST(AlterSchema_lint_2020_12, object_oneof_required_not_required_5) {
1021110211 LINT_WITHOUT_FIX (document, result, traces);
1021210212
1021310213 EXPECT_FALSE (result.first );
10214- EXPECT_EQ (traces.size (), 1 );
10214+ EXPECT_EQ (traces.size (), 2 );
10215+ EXPECT_LINT_TRACE (traces, 0 , " " , " oneof_min_branches" ,
10216+ " The `oneOf` keyword should have at least 2 branches to be "
10217+ " meaningful" ,
10218+ false );
1021510219 EXPECT_LINT_TRACE (
10216- traces, 0 , " /oneOf/0/items/not" , " required_properties_in_properties" ,
10220+ traces, 1 , " /oneOf/0/items/not" , " required_properties_in_properties" ,
1021710221 " Every property listed in the `required` keyword must be explicitly "
1021810222 " defined using the `properties` keyword" ,
1021910223 true );
@@ -13583,3 +13587,57 @@ TEST(AlterSchema_lint_2020_12, embedded_custom_metaschema) {
1358313587
1358413588 EXPECT_EQ (document, expected);
1358513589}
13590+
13591+ TEST (AlterSchema_lint_2020_12, oneof_min_branches_1) {
13592+ const sourcemeta::core::JSON document = sourcemeta::core::parse_json (R"JSON( {
13593+ "$schema": "https://json-schema.org/draft/2020-12/schema",
13594+ "title": "My Schema",
13595+ "description": "A schema",
13596+ "examples": [ "hello" ],
13597+ "oneOf": [ { "type": "string", "minLength": 5 }, { "type": "string", "maxLength": 3 } ]
13598+ })JSON" );
13599+
13600+ LINT_WITHOUT_FIX (document, result, traces);
13601+
13602+ EXPECT_TRUE (result.first );
13603+ EXPECT_EQ (traces.size (), 0 );
13604+ }
13605+
13606+ TEST (AlterSchema_lint_2020_12, oneof_min_branches_2) {
13607+ const sourcemeta::core::JSON document = sourcemeta::core::parse_json (R"JSON( {
13608+ "$schema": "https://json-schema.org/draft/2020-12/schema",
13609+ "title": "My Schema",
13610+ "description": "A schema",
13611+ "examples": [ "hello" ],
13612+ "oneOf": [ { "type": "string" } ]
13613+ })JSON" );
13614+
13615+ LINT_WITHOUT_FIX (document, result, traces);
13616+
13617+ EXPECT_FALSE (result.first );
13618+ EXPECT_EQ (traces.size (), 1 );
13619+ EXPECT_LINT_TRACE (traces, 0 , " " , " oneof_min_branches" ,
13620+ " The `oneOf` keyword should have at least 2 branches to "
13621+ " be meaningful" ,
13622+ false );
13623+ }
13624+
13625+ TEST (AlterSchema_lint_2020_12, oneof_min_branches_3) {
13626+ const sourcemeta::core::JSON document = sourcemeta::core::parse_json (R"JSON( {
13627+ "$schema": "https://json-schema.org/draft/2020-12/schema",
13628+ "title": "My Schema",
13629+ "description": "A schema",
13630+ "examples": [ "hello" ],
13631+ "not": { "oneOf": [] }
13632+ })JSON" );
13633+
13634+ LINT_WITHOUT_FIX (document, result, traces);
13635+
13636+ EXPECT_FALSE (result.first );
13637+ EXPECT_EQ (traces.size (), 1 );
13638+ EXPECT_LINT_TRACE (traces, 0 , " /not" , " oneof_min_branches" ,
13639+ " The `oneOf` keyword should have at least 2 branches to "
13640+ " be meaningful" ,
13641+ false );
13642+ }
13643+
0 commit comments