From 99864ff66fdc0b16bfa5b81f83cf245be4b05033 Mon Sep 17 00:00:00 2001 From: Suprith KG Date: Thu, 11 Apr 2024 15:14:04 +0530 Subject: [PATCH 1/8] added tests for propertyNames with additionalProperties/unevaluatedProperties, also with specification property --- tests/draft2020-12/propertyNames.json | 58 +++++++++++++++++++++++++++ 1 file changed, 58 insertions(+) diff --git a/tests/draft2020-12/propertyNames.json b/tests/draft2020-12/propertyNames.json index 7ecfb7ec..fa64c1e0 100644 --- a/tests/draft2020-12/propertyNames.json +++ b/tests/draft2020-12/propertyNames.json @@ -1,6 +1,7 @@ [ { "description": "propertyNames validation", + "specification": [ { "core": "10.3.2.4" } ], "schema": { "$schema": "https://json-schema.org/draft/2020-12/schema", "propertyNames": {"maxLength": 3} @@ -46,6 +47,7 @@ }, { "description": "propertyNames with boolean schema true", + "specification": [ { "core": "10.3.2.4", "quote": "The value of \"propertyNames\" MUST be a valid JSON Schema." } ], "schema": { "$schema": "https://json-schema.org/draft/2020-12/schema", "propertyNames": true @@ -65,6 +67,7 @@ }, { "description": "propertyNames with boolean schema false", + "specification": [ { "core": "10.3.2.4", "quote": "The value of \"propertyNames\" MUST be a valid JSON Schema." } ], "schema": { "$schema": "https://json-schema.org/draft/2020-12/schema", "propertyNames": false @@ -81,5 +84,60 @@ "valid": true } ] + }, + { + "description": "propertyNames with additionalProperties", + "specification": [ { "core": "10.3.2.4" }, { "core": "10.3.2.3", "quote": "The validation of propertyNames remains unaffected by the presence or absence of additionalProperties. \"propertyNames\" are validated independently, regardless of other sibling keywords" } ], + "schema": { + "$schema": "https://json-schema.org/draft/2020-12/schema", + "additionalProperties":{ + "type": "number" + }, + "propertyNames": { + "maxLength": 5 + } + }, + "tests": [ + { + "description": "property names with the given pattern are valid", + "data": {"apple": 4}, + "valid": true + }, + { + "description": "property name is invalid", + "data": { "watermelon": 6 }, + "valid": false + } + ] + }, + { + "description": "propertyNames with unevaluatedProperties", + "specification": [ { "core": "10.3.2.4" }, { "core":"11.3", "quote": "The validation of propertyNames remains unaffected by the presence or absence of unevaluatedProperties. \"propertyNames\" are validated independently, regardless of other sibling keywords" } ], + "schema": { + "$schema": "https://json-schema.org/draft/2020-12/schema", + "properties":{ + "banana":{ + "const": "available" + } + }, + "unevaluatedProperties":{ + "type": "number" + }, + "propertyNames": { + "pattern": "^[a-b]" + } + }, + "tests": [ + { + "description": "property names with the given pattern are valid", + "data": { "banana": "available", "apple": 4 }, + "valid": true + }, + { + "description": "property name chickoo is invalid", + "data": { "banana": "available", "chickoo": 10 }, + "valid": false + } + ] } ] From f08b884cf3316c24f6752feee2bab0201d4f9464 Mon Sep 17 00:00:00 2001 From: Suprith KG Date: Fri, 12 Apr 2024 11:40:23 +0530 Subject: [PATCH 2/8] Cases go under additional and unevaluated Properties --- tests/draft2020-12/additionalProperties.json | 24 ++++++++ tests/draft2020-12/propertyNames.json | 60 +------------------ tests/draft2020-12/unevaluatedProperties.json | 30 ++++++++++ 3 files changed, 55 insertions(+), 59 deletions(-) diff --git a/tests/draft2020-12/additionalProperties.json b/tests/draft2020-12/additionalProperties.json index cae4d3c7..a453002d 100644 --- a/tests/draft2020-12/additionalProperties.json +++ b/tests/draft2020-12/additionalProperties.json @@ -158,5 +158,29 @@ "valid": true } ] + }, + { + "description": "additionalProperties with propertyNames", + "schema": { + "$schema": "https://json-schema.org/draft/2020-12/schema", + "propertyNames": { + "maxLength": 5 + }, + "additionalProperties":{ + "type": "number" + } + }, + "tests": [ + { + "description": "Valid against both keywords", + "data": {"apple": 4}, + "valid": true + }, + { + "description": "Valid against propertyNames, but not unevaluatedProperties", + "data": { "fig": 2, "pear": "available" }, + "valid": false + } + ] } ] diff --git a/tests/draft2020-12/propertyNames.json b/tests/draft2020-12/propertyNames.json index fa64c1e0..05dad87c 100644 --- a/tests/draft2020-12/propertyNames.json +++ b/tests/draft2020-12/propertyNames.json @@ -1,7 +1,6 @@ [ { "description": "propertyNames validation", - "specification": [ { "core": "10.3.2.4" } ], "schema": { "$schema": "https://json-schema.org/draft/2020-12/schema", "propertyNames": {"maxLength": 3} @@ -47,7 +46,6 @@ }, { "description": "propertyNames with boolean schema true", - "specification": [ { "core": "10.3.2.4", "quote": "The value of \"propertyNames\" MUST be a valid JSON Schema." } ], "schema": { "$schema": "https://json-schema.org/draft/2020-12/schema", "propertyNames": true @@ -67,7 +65,6 @@ }, { "description": "propertyNames with boolean schema false", - "specification": [ { "core": "10.3.2.4", "quote": "The value of \"propertyNames\" MUST be a valid JSON Schema." } ], "schema": { "$schema": "https://json-schema.org/draft/2020-12/schema", "propertyNames": false @@ -84,60 +81,5 @@ "valid": true } ] - }, - { - "description": "propertyNames with additionalProperties", - "specification": [ { "core": "10.3.2.4" }, { "core": "10.3.2.3", "quote": "The validation of propertyNames remains unaffected by the presence or absence of additionalProperties. \"propertyNames\" are validated independently, regardless of other sibling keywords" } ], - "schema": { - "$schema": "https://json-schema.org/draft/2020-12/schema", - "additionalProperties":{ - "type": "number" - }, - "propertyNames": { - "maxLength": 5 - } - }, - "tests": [ - { - "description": "property names with the given pattern are valid", - "data": {"apple": 4}, - "valid": true - }, - { - "description": "property name is invalid", - "data": { "watermelon": 6 }, - "valid": false - } - ] - }, - { - "description": "propertyNames with unevaluatedProperties", - "specification": [ { "core": "10.3.2.4" }, { "core":"11.3", "quote": "The validation of propertyNames remains unaffected by the presence or absence of unevaluatedProperties. \"propertyNames\" are validated independently, regardless of other sibling keywords" } ], - "schema": { - "$schema": "https://json-schema.org/draft/2020-12/schema", - "properties":{ - "banana":{ - "const": "available" - } - }, - "unevaluatedProperties":{ - "type": "number" - }, - "propertyNames": { - "pattern": "^[a-b]" - } - }, - "tests": [ - { - "description": "property names with the given pattern are valid", - "data": { "banana": "available", "apple": 4 }, - "valid": true - }, - { - "description": "property name chickoo is invalid", - "data": { "banana": "available", "chickoo": 10 }, - "valid": false - } - ] } -] +] \ No newline at end of file diff --git a/tests/draft2020-12/unevaluatedProperties.json b/tests/draft2020-12/unevaluatedProperties.json index b8a2306c..a65c09b3 100644 --- a/tests/draft2020-12/unevaluatedProperties.json +++ b/tests/draft2020-12/unevaluatedProperties.json @@ -1564,5 +1564,35 @@ "valid": false } ] + }, + { + "description": "unevaluatedProperties with propertyNames", + "schema": { + "$schema": "https://json-schema.org/draft/2020-12/schema", + "properties":{ + "banana":{ + "const": "available" + } + }, + "propertyNames": { + "pattern": "^[a-b]" + }, + "unevaluatedProperties":{ + "type": "number" + } + + }, + "tests": [ + { + "description": "Valid against all constraints", + "data": { "banana": "available", "apple": 4 }, + "valid": true + }, + { + "description": "valid against propertyNames, but not unevaluatedProperties", + "data": { "banana": "available", "apple": true }, + "valid": false + } + ] } ] From 964efb8e6398dcc98555e709e7f72456ca8c3af3 Mon Sep 17 00:00:00 2001 From: Suprith KG Date: Fri, 12 Apr 2024 15:13:58 +0530 Subject: [PATCH 3/8] propertyNames doesn't affect additionalProperties, tests exist already for unevaluatedProps --- tests/draft-next/additionalProperties.json | 24 +++++++++++++++ tests/draft2019-09/additionalProperties.json | 24 +++++++++++++++ tests/draft2020-12/unevaluatedProperties.json | 30 ------------------- 3 files changed, 48 insertions(+), 30 deletions(-) diff --git a/tests/draft-next/additionalProperties.json b/tests/draft-next/additionalProperties.json index 7859fbbf..4538fad4 100644 --- a/tests/draft-next/additionalProperties.json +++ b/tests/draft-next/additionalProperties.json @@ -152,5 +152,29 @@ "valid": true } ] + }, + { + "description": "additionalProperties with propertyNames", + "schema": { + "$schema": "https://json-schema.org/draft/next/schema", + "propertyNames": { + "maxLength": 5 + }, + "additionalProperties":{ + "type": "number" + } + }, + "tests": [ + { + "description": "Valid against both keywords", + "data": {"apple": 4}, + "valid": true + }, + { + "description": "Valid against propertyNames, but not unevaluatedProperties", + "data": { "fig": 2, "pear": "available" }, + "valid": false + } + ] } ] diff --git a/tests/draft2019-09/additionalProperties.json b/tests/draft2019-09/additionalProperties.json index f9f03bb0..a74105f7 100644 --- a/tests/draft2019-09/additionalProperties.json +++ b/tests/draft2019-09/additionalProperties.json @@ -152,5 +152,29 @@ "valid": true } ] + }, + { + "description": "additionalProperties with propertyNames", + "schema": { + "$schema": "https://json-schema.org/draft/next/schema", + "propertyNames": { + "maxLength": 5 + }, + "additionalProperties":{ + "type": "number" + } + }, + "tests": [ + { + "description": "Valid against both keywords", + "data": {"apple": 4}, + "valid": true + }, + { + "description": "Valid against propertyNames, but not unevaluatedProperties", + "data": { "fig": 2, "pear": "available" }, + "valid": false + } + ] } ] diff --git a/tests/draft2020-12/unevaluatedProperties.json b/tests/draft2020-12/unevaluatedProperties.json index a65c09b3..b8a2306c 100644 --- a/tests/draft2020-12/unevaluatedProperties.json +++ b/tests/draft2020-12/unevaluatedProperties.json @@ -1564,35 +1564,5 @@ "valid": false } ] - }, - { - "description": "unevaluatedProperties with propertyNames", - "schema": { - "$schema": "https://json-schema.org/draft/2020-12/schema", - "properties":{ - "banana":{ - "const": "available" - } - }, - "propertyNames": { - "pattern": "^[a-b]" - }, - "unevaluatedProperties":{ - "type": "number" - } - - }, - "tests": [ - { - "description": "Valid against all constraints", - "data": { "banana": "available", "apple": 4 }, - "valid": true - }, - { - "description": "valid against propertyNames, but not unevaluatedProperties", - "data": { "banana": "available", "apple": true }, - "valid": false - } - ] } ] From c5f3e4eaa568cd1261de27b054ec93c8169d42e5 Mon Sep 17 00:00:00 2001 From: Suprith KG Date: Sat, 13 Apr 2024 13:53:21 +0530 Subject: [PATCH 4/8] Update tests/draft2020-12/propertyNames.json Co-authored-by: Jason Desrosiers --- tests/draft2020-12/propertyNames.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/draft2020-12/propertyNames.json b/tests/draft2020-12/propertyNames.json index 05dad87c..7ecfb7ec 100644 --- a/tests/draft2020-12/propertyNames.json +++ b/tests/draft2020-12/propertyNames.json @@ -82,4 +82,4 @@ } ] } -] \ No newline at end of file +] From 616240b06ab4a2e49f05764fa8e85bb67075beea Mon Sep 17 00:00:00 2001 From: Suprith KG Date: Sat, 13 Apr 2024 13:53:31 +0530 Subject: [PATCH 5/8] Update tests/draft-next/additionalProperties.json Co-authored-by: Jason Desrosiers --- tests/draft-next/additionalProperties.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/draft-next/additionalProperties.json b/tests/draft-next/additionalProperties.json index 4538fad4..9fb59d6c 100644 --- a/tests/draft-next/additionalProperties.json +++ b/tests/draft-next/additionalProperties.json @@ -167,7 +167,7 @@ "tests": [ { "description": "Valid against both keywords", - "data": {"apple": 4}, + "data": { "apple": 4 }, "valid": true }, { From 3e0139a54d45eeaca5f5fe1dc35c79f8d1433a40 Mon Sep 17 00:00:00 2001 From: Suprith KG Date: Sat, 13 Apr 2024 13:53:45 +0530 Subject: [PATCH 6/8] Update tests/draft-next/additionalProperties.json Co-authored-by: Jason Desrosiers --- tests/draft-next/additionalProperties.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/draft-next/additionalProperties.json b/tests/draft-next/additionalProperties.json index 9fb59d6c..606635e4 100644 --- a/tests/draft-next/additionalProperties.json +++ b/tests/draft-next/additionalProperties.json @@ -160,7 +160,7 @@ "propertyNames": { "maxLength": 5 }, - "additionalProperties":{ + "additionalProperties": { "type": "number" } }, From 6aa79c0b23e4f820e124b872f3e593c571e1058a Mon Sep 17 00:00:00 2001 From: Suprith KG Date: Sat, 13 Apr 2024 13:56:40 +0530 Subject: [PATCH 7/8] Update additionalProperties.json formatting it --- tests/draft2019-09/additionalProperties.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/draft2019-09/additionalProperties.json b/tests/draft2019-09/additionalProperties.json index a74105f7..dab3e89b 100644 --- a/tests/draft2019-09/additionalProperties.json +++ b/tests/draft2019-09/additionalProperties.json @@ -160,14 +160,14 @@ "propertyNames": { "maxLength": 5 }, - "additionalProperties":{ + "additionalProperties": { "type": "number" } }, "tests": [ { "description": "Valid against both keywords", - "data": {"apple": 4}, + "data": { "apple": 4 }, "valid": true }, { From 2480edbaed02baf5c810a56fa49745524a4e0574 Mon Sep 17 00:00:00 2001 From: Suprith KG Date: Sat, 13 Apr 2024 13:57:26 +0530 Subject: [PATCH 8/8] Update additionalProperties.json formatting it --- tests/draft2020-12/additionalProperties.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/draft2020-12/additionalProperties.json b/tests/draft2020-12/additionalProperties.json index a453002d..d48a498a 100644 --- a/tests/draft2020-12/additionalProperties.json +++ b/tests/draft2020-12/additionalProperties.json @@ -166,14 +166,14 @@ "propertyNames": { "maxLength": 5 }, - "additionalProperties":{ + "additionalProperties": { "type": "number" } }, "tests": [ { "description": "Valid against both keywords", - "data": {"apple": 4}, + "data": { "apple": 4 }, "valid": true }, {