From 7dfbb1e94c66fe5141e6432e7d0bfa28771aa4d8 Mon Sep 17 00:00:00 2001 From: "Kai A. Hiller" Date: Wed, 20 Nov 2024 17:05:44 +0100 Subject: [PATCH 1/4] Add test for unevaluatedProperties --- tests/draft2020-12/unevaluatedProperties.json | 25 +++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/tests/draft2020-12/unevaluatedProperties.json b/tests/draft2020-12/unevaluatedProperties.json index ae29c9eb..5ac4b36c 100644 --- a/tests/draft2020-12/unevaluatedProperties.json +++ b/tests/draft2020-12/unevaluatedProperties.json @@ -160,6 +160,31 @@ } ] }, + { + "description": "unevaluatedProperties with non-bool additionalProperties", + "schema": { + "$schema": "https://json-schema.org/draft/2020-12/schema", + "additionalProperties": { "type": "string" }, + "unevaluatedProperties": false + }, + "tests": [ + { + "description": "with only valid additional properties", + "data": { + "foo": "foo" + }, + "valid": true + }, + { + "description": "with invalid additional properties", + "data": { + "foo": "foo", + "bar": 1 + }, + "valid": false + } + ] + }, { "description": "unevaluatedProperties with nested properties", "schema": { From 347d609922929a293cc751db8ed5ae76215ce5a5 Mon Sep 17 00:00:00 2001 From: "Kai A. Hiller" Date: Sat, 23 Nov 2024 21:57:54 +0100 Subject: [PATCH 2/4] unevaluatedProperties: Remove type keywords --- tests/draft2020-12/unevaluatedProperties.json | 32 ------------------- 1 file changed, 32 deletions(-) diff --git a/tests/draft2020-12/unevaluatedProperties.json b/tests/draft2020-12/unevaluatedProperties.json index 5ac4b36c..16db9d21 100644 --- a/tests/draft2020-12/unevaluatedProperties.json +++ b/tests/draft2020-12/unevaluatedProperties.json @@ -3,7 +3,6 @@ "description": "unevaluatedProperties true", "schema": { "$schema": "https://json-schema.org/draft/2020-12/schema", - "type": "object", "unevaluatedProperties": true }, "tests": [ @@ -25,7 +24,6 @@ "description": "unevaluatedProperties schema", "schema": { "$schema": "https://json-schema.org/draft/2020-12/schema", - "type": "object", "unevaluatedProperties": { "type": "string", "minLength": 3 @@ -57,7 +55,6 @@ "description": "unevaluatedProperties false", "schema": { "$schema": "https://json-schema.org/draft/2020-12/schema", - "type": "object", "unevaluatedProperties": false }, "tests": [ @@ -79,7 +76,6 @@ "description": "unevaluatedProperties with adjacent properties", "schema": { "$schema": "https://json-schema.org/draft/2020-12/schema", - "type": "object", "properties": { "foo": { "type": "string" } }, @@ -107,7 +103,6 @@ "description": "unevaluatedProperties with adjacent patternProperties", "schema": { "$schema": "https://json-schema.org/draft/2020-12/schema", - "type": "object", "patternProperties": { "^foo": { "type": "string" } }, @@ -135,7 +130,6 @@ "description": "unevaluatedProperties with adjacent additionalProperties", "schema": { "$schema": "https://json-schema.org/draft/2020-12/schema", - "type": "object", "properties": { "foo": { "type": "string" } }, @@ -189,7 +183,6 @@ "description": "unevaluatedProperties with nested properties", "schema": { "$schema": "https://json-schema.org/draft/2020-12/schema", - "type": "object", "properties": { "foo": { "type": "string" } }, @@ -226,7 +219,6 @@ "description": "unevaluatedProperties with nested patternProperties", "schema": { "$schema": "https://json-schema.org/draft/2020-12/schema", - "type": "object", "properties": { "foo": { "type": "string" } }, @@ -263,7 +255,6 @@ "description": "unevaluatedProperties with nested additionalProperties", "schema": { "$schema": "https://json-schema.org/draft/2020-12/schema", - "type": "object", "properties": { "foo": { "type": "string" } }, @@ -296,7 +287,6 @@ "description": "unevaluatedProperties with nested unevaluatedProperties", "schema": { "$schema": "https://json-schema.org/draft/2020-12/schema", - "type": "object", "properties": { "foo": { "type": "string" } }, @@ -332,7 +322,6 @@ "description": "unevaluatedProperties with anyOf", "schema": { "$schema": "https://json-schema.org/draft/2020-12/schema", - "type": "object", "properties": { "foo": { "type": "string" } }, @@ -401,7 +390,6 @@ "description": "unevaluatedProperties with oneOf", "schema": { "$schema": "https://json-schema.org/draft/2020-12/schema", - "type": "object", "properties": { "foo": { "type": "string" } }, @@ -445,7 +433,6 @@ "description": "unevaluatedProperties with not", "schema": { "$schema": "https://json-schema.org/draft/2020-12/schema", - "type": "object", "properties": { "foo": { "type": "string" } }, @@ -474,7 +461,6 @@ "description": "unevaluatedProperties with if/then/else", "schema": { "$schema": "https://json-schema.org/draft/2020-12/schema", - "type": "object", "if": { "properties": { "foo": { "const": "then" } @@ -534,7 +520,6 @@ "description": "unevaluatedProperties with if/then/else, then not defined", "schema": { "$schema": "https://json-schema.org/draft/2020-12/schema", - "type": "object", "if": { "properties": { "foo": { "const": "then" } @@ -588,7 +573,6 @@ "description": "unevaluatedProperties with if/then/else, else not defined", "schema": { "$schema": "https://json-schema.org/draft/2020-12/schema", - "type": "object", "if": { "properties": { "foo": { "const": "then" } @@ -642,7 +626,6 @@ "description": "unevaluatedProperties with dependentSchemas", "schema": { "$schema": "https://json-schema.org/draft/2020-12/schema", - "type": "object", "properties": { "foo": { "type": "string" } }, @@ -678,7 +661,6 @@ "description": "unevaluatedProperties with boolean schemas", "schema": { "$schema": "https://json-schema.org/draft/2020-12/schema", - "type": "object", "properties": { "foo": { "type": "string" } }, @@ -706,7 +688,6 @@ "description": "unevaluatedProperties with $ref", "schema": { "$schema": "https://json-schema.org/draft/2020-12/schema", - "type": "object", "$ref": "#/$defs/bar", "properties": { "foo": { "type": "string" } @@ -744,7 +725,6 @@ "description": "unevaluatedProperties before $ref", "schema": { "$schema": "https://json-schema.org/draft/2020-12/schema", - "type": "object", "unevaluatedProperties": false, "properties": { "foo": { "type": "string" } @@ -798,7 +778,6 @@ "$comment": "unevaluatedProperties comes first so it's more likely to catch bugs with implementations that are sensitive to keyword ordering", "unevaluatedProperties": false, - "type": "object", "properties": { "foo": { "type": "string" } }, @@ -887,7 +866,6 @@ "description": "nested unevaluatedProperties, outer false, inner true, properties outside", "schema": { "$schema": "https://json-schema.org/draft/2020-12/schema", - "type": "object", "properties": { "foo": { "type": "string" } }, @@ -920,7 +898,6 @@ "description": "nested unevaluatedProperties, outer false, inner true, properties inside", "schema": { "$schema": "https://json-schema.org/draft/2020-12/schema", - "type": "object", "allOf": [ { "properties": { @@ -953,7 +930,6 @@ "description": "nested unevaluatedProperties, outer true, inner false, properties outside", "schema": { "$schema": "https://json-schema.org/draft/2020-12/schema", - "type": "object", "properties": { "foo": { "type": "string" } }, @@ -986,7 +962,6 @@ "description": "nested unevaluatedProperties, outer true, inner false, properties inside", "schema": { "$schema": "https://json-schema.org/draft/2020-12/schema", - "type": "object", "allOf": [ { "properties": { @@ -1019,7 +994,6 @@ "description": "cousin unevaluatedProperties, true and false, true with properties", "schema": { "$schema": "https://json-schema.org/draft/2020-12/schema", - "type": "object", "allOf": [ { "properties": { @@ -1054,7 +1028,6 @@ "description": "cousin unevaluatedProperties, true and false, false with properties", "schema": { "$schema": "https://json-schema.org/draft/2020-12/schema", - "type": "object", "allOf": [ { "unevaluatedProperties": true @@ -1090,10 +1063,8 @@ "comment": "see https://stackoverflow.com/questions/66936884/deeply-nested-unevaluatedproperties-and-their-expectations", "schema": { "$schema": "https://json-schema.org/draft/2020-12/schema", - "type": "object", "properties": { "foo": { - "type": "object", "properties": { "bar": { "type": "string" @@ -1142,7 +1113,6 @@ "description": "in-place applicator siblings, allOf has unevaluated", "schema": { "$schema": "https://json-schema.org/draft/2020-12/schema", - "type": "object", "allOf": [ { "properties": { @@ -1188,7 +1158,6 @@ "description": "in-place applicator siblings, anyOf has unevaluated", "schema": { "$schema": "https://json-schema.org/draft/2020-12/schema", - "type": "object", "allOf": [ { "properties": { @@ -1234,7 +1203,6 @@ "description": "unevaluatedProperties + single cyclic ref", "schema": { "$schema": "https://json-schema.org/draft/2020-12/schema", - "type": "object", "properties": { "x": { "$ref": "#" } }, From 43828feecccd47dcfc701e0f12008ef931f4745b Mon Sep 17 00:00:00 2001 From: "Kai A. Hiller" Date: Sat, 23 Nov 2024 21:53:46 +0100 Subject: [PATCH 3/4] Simplify adjacent additionalProperties test --- tests/draft2020-12/unevaluatedProperties.json | 3 --- 1 file changed, 3 deletions(-) diff --git a/tests/draft2020-12/unevaluatedProperties.json b/tests/draft2020-12/unevaluatedProperties.json index 16db9d21..04063a2c 100644 --- a/tests/draft2020-12/unevaluatedProperties.json +++ b/tests/draft2020-12/unevaluatedProperties.json @@ -130,9 +130,6 @@ "description": "unevaluatedProperties with adjacent additionalProperties", "schema": { "$schema": "https://json-schema.org/draft/2020-12/schema", - "properties": { - "foo": { "type": "string" } - }, "additionalProperties": true, "unevaluatedProperties": false }, From 5273e0d6e2503d092b0bdea0abd64863e565aeea Mon Sep 17 00:00:00 2001 From: "Kai A. Hiller" Date: Sat, 23 Nov 2024 22:11:46 +0100 Subject: [PATCH 4/4] Make test descriptions more specific --- tests/draft2020-12/unevaluatedProperties.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/draft2020-12/unevaluatedProperties.json b/tests/draft2020-12/unevaluatedProperties.json index 04063a2c..0da38f67 100644 --- a/tests/draft2020-12/unevaluatedProperties.json +++ b/tests/draft2020-12/unevaluatedProperties.json @@ -127,7 +127,7 @@ ] }, { - "description": "unevaluatedProperties with adjacent additionalProperties", + "description": "unevaluatedProperties with adjacent bool additionalProperties", "schema": { "$schema": "https://json-schema.org/draft/2020-12/schema", "additionalProperties": true, @@ -152,7 +152,7 @@ ] }, { - "description": "unevaluatedProperties with non-bool additionalProperties", + "description": "unevaluatedProperties with adjacent non-bool additionalProperties", "schema": { "$schema": "https://json-schema.org/draft/2020-12/schema", "additionalProperties": { "type": "string" },