From e0e431f8eded9c4ce056034f6a11bbd62a8bfc83 Mon Sep 17 00:00:00 2001 From: Owen Shepherd Date: Tue, 11 Nov 2025 15:07:08 +0000 Subject: [PATCH] Fix unevaluatedProperties & additionalProperties test case This fixes the disparaty between then 2019, 2020, and v1 drafts, and adds the property constraint back into the 2020 schema, so that the first test case matches its description. --- tests/draft2019-09/unevaluatedProperties.json | 31 ++++++++++++++++++- tests/draft2020-12/unevaluatedProperties.json | 18 ++++++++--- tests/v1/unevaluatedProperties.json | 31 ++++++++++++++++++- 3 files changed, 73 insertions(+), 7 deletions(-) diff --git a/tests/draft2019-09/unevaluatedProperties.json b/tests/draft2019-09/unevaluatedProperties.json index 4a89d390..e18427c0 100644 --- a/tests/draft2019-09/unevaluatedProperties.json +++ b/tests/draft2019-09/unevaluatedProperties.json @@ -132,7 +132,7 @@ ] }, { - "description": "unevaluatedProperties with adjacent additionalProperties", + "description": "unevaluatedProperties with adjacent bool additionalProperties", "schema": { "$schema": "https://json-schema.org/draft/2019-09/schema", "type": "object", @@ -160,6 +160,35 @@ } ] }, + { + "description": "unevaluatedProperties with adjacent non-bool additionalProperties", + "schema": { + "$schema": "https://json-schema.org/draft/2019-09/schema", + "type": "object", + "properties": { + "foo": { "type": "string" } + }, + "additionalProperties": {"type": "string"}, + "unevaluatedProperties": false + }, + "tests": [ + { + "description": "with no additional properties", + "data": { + "foo": "foo" + }, + "valid": true + }, + { + "description": "with additional properties", + "data": { + "foo": "foo", + "bar": "bar" + }, + "valid": true + } + ] + }, { "description": "unevaluatedProperties with nested properties", "schema": { diff --git a/tests/draft2020-12/unevaluatedProperties.json b/tests/draft2020-12/unevaluatedProperties.json index 9c18b9ef..a2507481 100644 --- a/tests/draft2020-12/unevaluatedProperties.json +++ b/tests/draft2020-12/unevaluatedProperties.json @@ -130,6 +130,10 @@ "description": "unevaluatedProperties with adjacent bool additionalProperties", "schema": { "$schema": "https://json-schema.org/draft/2020-12/schema", + "type": "object", + "properties": { + "foo": { "type": "string" } + }, "additionalProperties": true, "unevaluatedProperties": false }, @@ -155,24 +159,28 @@ "description": "unevaluatedProperties with adjacent non-bool additionalProperties", "schema": { "$schema": "https://json-schema.org/draft/2020-12/schema", - "additionalProperties": { "type": "string" }, + "type": "object", + "properties": { + "foo": { "type": "string" } + }, + "additionalProperties": {"type": "string"}, "unevaluatedProperties": false }, "tests": [ { - "description": "with only valid additional properties", + "description": "with no additional properties", "data": { "foo": "foo" }, "valid": true }, { - "description": "with invalid additional properties", + "description": "with additional properties", "data": { "foo": "foo", - "bar": 1 + "bar": "bar" }, - "valid": false + "valid": true } ] }, diff --git a/tests/v1/unevaluatedProperties.json b/tests/v1/unevaluatedProperties.json index f1d40fdc..36b9ffb4 100644 --- a/tests/v1/unevaluatedProperties.json +++ b/tests/v1/unevaluatedProperties.json @@ -132,7 +132,7 @@ ] }, { - "description": "unevaluatedProperties with adjacent additionalProperties", + "description": "unevaluatedProperties with adjacent bool additionalProperties", "schema": { "$schema": "https://json-schema.org/v1", "type": "object", @@ -160,6 +160,35 @@ } ] }, + { + "description": "unevaluatedProperties with adjacent non-bool additionalProperties", + "schema": { + "$schema": "https://json-schema.org/v1", + "type": "object", + "properties": { + "foo": { "type": "string" } + }, + "additionalProperties": {"type": "string"}, + "unevaluatedProperties": false + }, + "tests": [ + { + "description": "with no additional properties", + "data": { + "foo": "foo" + }, + "valid": true + }, + { + "description": "with additional properties", + "data": { + "foo": "foo", + "bar": "bar" + }, + "valid": true + } + ] + }, { "description": "unevaluatedProperties with nested properties", "schema": {