From 50a20280b39d6914c1eb3c88e61c24f9e84bc13b Mon Sep 17 00:00:00 2001 From: Suprith KG Date: Wed, 3 Apr 2024 22:28:58 +0530 Subject: [PATCH 1/6] adding specification enhancement for additionalProperties --- tests/draft2020-12/additionalProperties.json | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/tests/draft2020-12/additionalProperties.json b/tests/draft2020-12/additionalProperties.json index 29e69c13..52d697a0 100644 --- a/tests/draft2020-12/additionalProperties.json +++ b/tests/draft2020-12/additionalProperties.json @@ -2,6 +2,9 @@ { "description": "additionalProperties being false does not allow other properties", + "specification":{ + "jsonschema":"https://json-schema.org/draft/2020-12/draft-bhutton-json-schema-01#section-10.3.2.3-1" + }, "schema": { "$schema": "https://json-schema.org/draft/2020-12/schema", "properties": {"foo": {}, "bar": {}}, @@ -63,6 +66,9 @@ }, { "description": "additionalProperties with schema", + "specification":{ + "jsonschema":"https://json-schema.org/draft/2020-12/draft-bhutton-json-schema-01#section-10.3.2.3-1" + }, "schema": { "$schema": "https://json-schema.org/draft/2020-12/schema", "properties": {"foo": {}, "bar": {}}, @@ -108,6 +114,9 @@ }, { "description": "additionalProperties are allowed by default", + "specification":{ + "jsonschema":"https://json-schema.org/draft/2020-12/draft-bhutton-json-schema-01#section-10.3.2.3-5" + }, "schema": { "$schema": "https://json-schema.org/draft/2020-12/schema", "properties": {"foo": {}, "bar": {}} @@ -122,6 +131,9 @@ }, { "description": "additionalProperties does not look in applicators", + "specification":{ + "jsonschema":"https://json-schema.org/draft/2020-12/draft-bhutton-json-schema-01#section-10.2-2" + }, "schema": { "$schema": "https://json-schema.org/draft/2020-12/schema", "allOf": [ @@ -139,6 +151,9 @@ }, { "description": "additionalProperties with null valued instance properties", + "specification":{ + "jsonschema": "https://json-schema.org/draft/2020-12/draft-bhutton-json-schema-01#section-10.3.2.3-1" + }, "schema": { "$schema": "https://json-schema.org/draft/2020-12/schema", "additionalProperties": { From 003ac02119f9f849d67880115f9ca4cb1dae0083 Mon Sep 17 00:00:00 2001 From: Suprith KG Date: Wed, 3 Apr 2024 23:33:46 +0530 Subject: [PATCH 2/6] Test-schema including sub-schema for scpecification --- test-schema.json | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/test-schema.json b/test-schema.json index 83393162..f9ad2a09 100644 --- a/test-schema.json +++ b/test-schema.json @@ -27,6 +27,16 @@ "type": "array", "items": { "$ref": "#/$defs/test" }, "minItems": 1 + }, + "specification":{ + "description": "Location of the test case in the specification", + "type": "object", + "minProperties": 1, + "properties":{ + "jsonschema": {"type": "string"}, + "rfc": {"type": "string"} + }, + "additionalProperties": false } }, "additionalProperties": false From 340116ecf8c2d02942b86fdfbc170a50ec5f08c9 Mon Sep 17 00:00:00 2001 From: Suprith KG Date: Thu, 4 Apr 2024 20:05:45 +0530 Subject: [PATCH 3/6] Schema of specification in much structured --- test-schema.json | 22 ++++++++++++-- tests/draft2020-12/additionalProperties.json | 30 ++++++++++++++++---- 2 files changed, 44 insertions(+), 8 deletions(-) diff --git a/test-schema.json b/test-schema.json index f9ad2a09..ce98f19b 100644 --- a/test-schema.json +++ b/test-schema.json @@ -32,9 +32,13 @@ "description": "Location of the test case in the specification", "type": "object", "minProperties": 1, - "properties":{ - "jsonschema": {"type": "string"}, - "rfc": {"type": "string"} + "properties": { + "jsonschema-core": { "$ref": "#/$defs/spec"}, + "jsonschema-validation": {"$ref": "#/$defs/spec"}, + "ecma262": { "$ref": "#/$defs/spec"} + }, + "patternProperties": { + "^rfc[0-9]{4}$": {"$ref": "#/$defs/spec"} }, "additionalProperties": false } @@ -66,6 +70,18 @@ } }, "additionalProperties": false + }, + "spec": { + "properties": { + "section": { + "type": "string", + "pattern": "^\\d+(\\.\\d+)*\\.$" + }, + "para": { + "type": "string", + "pattern": "^\\d+(\\.\\d+)*\\.$" + } + } } } } diff --git a/tests/draft2020-12/additionalProperties.json b/tests/draft2020-12/additionalProperties.json index 52d697a0..22df0dac 100644 --- a/tests/draft2020-12/additionalProperties.json +++ b/tests/draft2020-12/additionalProperties.json @@ -3,7 +3,10 @@ "description": "additionalProperties being false does not allow other properties", "specification":{ - "jsonschema":"https://json-schema.org/draft/2020-12/draft-bhutton-json-schema-01#section-10.3.2.3-1" + "jsonschema-core": { + "section": "10.3.2.3.", + "para": "1" + } }, "schema": { "$schema": "https://json-schema.org/draft/2020-12/schema", @@ -46,6 +49,11 @@ }, { "description": "non-ASCII pattern with additionalProperties", + "specification":{ + "rfc8259":{ + "section": "4." + } + }, "schema": { "$schema": "https://json-schema.org/draft/2020-12/schema", "patternProperties": {"^á": {}}, @@ -67,7 +75,10 @@ { "description": "additionalProperties with schema", "specification":{ - "jsonschema":"https://json-schema.org/draft/2020-12/draft-bhutton-json-schema-01#section-10.3.2.3-1" + "jsonschema-core": { + "section": "10.3.2.3.", + "para": "1" + } }, "schema": { "$schema": "https://json-schema.org/draft/2020-12/schema", @@ -115,7 +126,10 @@ { "description": "additionalProperties are allowed by default", "specification":{ - "jsonschema":"https://json-schema.org/draft/2020-12/draft-bhutton-json-schema-01#section-10.3.2.3-5" + "jsonschema-core": { + "section": "10.3.2.3.", + "para": "5" + } }, "schema": { "$schema": "https://json-schema.org/draft/2020-12/schema", @@ -132,7 +146,10 @@ { "description": "additionalProperties does not look in applicators", "specification":{ - "jsonschema":"https://json-schema.org/draft/2020-12/draft-bhutton-json-schema-01#section-10.2-2" + "jsonschema-core": { + "section": "10.2.", + "para": "2" + } }, "schema": { "$schema": "https://json-schema.org/draft/2020-12/schema", @@ -152,7 +169,10 @@ { "description": "additionalProperties with null valued instance properties", "specification":{ - "jsonschema": "https://json-schema.org/draft/2020-12/draft-bhutton-json-schema-01#section-10.3.2.3-1" + "jsonschema-core": { + "section": "10.3.2.3.", + "para": "1" + } }, "schema": { "$schema": "https://json-schema.org/draft/2020-12/schema", From 1362a8ccea1ead72954868bbafa3a650c2795afc Mon Sep 17 00:00:00 2001 From: Suprith KG Date: Thu, 4 Apr 2024 20:10:30 +0530 Subject: [PATCH 4/6] Pattern for para corrected --- test-schema.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test-schema.json b/test-schema.json index ce98f19b..0f4ad640 100644 --- a/test-schema.json +++ b/test-schema.json @@ -79,7 +79,7 @@ }, "para": { "type": "string", - "pattern": "^\\d+(\\.\\d+)*\\.$" + "pattern": "^\\d+(\\.\\d+)*$" } } } From 9b169bed8e101573bc5b5f1431c920c578f610ba Mon Sep 17 00:00:00 2001 From: Suprith KG Date: Fri, 5 Apr 2024 23:05:47 +0530 Subject: [PATCH 5/6] specification takes array of objects having section and quote --- test-schema.json | 42 ++++++++---------- tests/draft2020-12/additionalProperties.json | 45 ++++---------------- 2 files changed, 26 insertions(+), 61 deletions(-) diff --git a/test-schema.json b/test-schema.json index 0f4ad640..5de3917d 100644 --- a/test-schema.json +++ b/test-schema.json @@ -29,18 +29,24 @@ "minItems": 1 }, "specification":{ - "description": "Location of the test case in the specification", - "type": "object", - "minProperties": 1, - "properties": { - "jsonschema-core": { "$ref": "#/$defs/spec"}, - "jsonschema-validation": {"$ref": "#/$defs/spec"}, - "ecma262": { "$ref": "#/$defs/spec"} - }, - "patternProperties": { - "^rfc[0-9]{4}$": {"$ref": "#/$defs/spec"} - }, - "additionalProperties": false + "description": "A reference to a specification document which defines the behavior tested by this test case. Typically this should be a JSON Schema specification document, though in cases where the JSON Schema specification points to another RFC it should contain *both* the portion of the JSON Schema specification which indicates what RFC (and section) to follow as *well* as information on where in that specification the behavior is specified.", + + "type": "array", + "minItems": 1, + "items":{ + "properties": { + "core": { "pattern": "^[0-9a-zA-Z]+(\\.[0-9a-zA-Z]+)*$", "type":"string" }, + "validation": { "pattern": "^[0-9a-zA-Z]+(\\.[0-9a-zA-Z]+)*$", "type":"string" }, + "ecma262": { "pattern": "^[0-9a-zA-Z]+(\\.[0-9a-zA-Z]+)*$", "type":"string" }, + "perl5": { "type":"string" }, + "quote": { "type":"string" } + }, + "patternProperties": { + "^rfc\\d+$": { "pattern": "^[0-9a-zA-Z]+.([0-9a-zA-Z]+)*$", "type":"string" } + }, + "additionalProperties": false, + "minProperties": 1 + } } }, "additionalProperties": false @@ -70,18 +76,6 @@ } }, "additionalProperties": false - }, - "spec": { - "properties": { - "section": { - "type": "string", - "pattern": "^\\d+(\\.\\d+)*\\.$" - }, - "para": { - "type": "string", - "pattern": "^\\d+(\\.\\d+)*$" - } - } } } } diff --git a/tests/draft2020-12/additionalProperties.json b/tests/draft2020-12/additionalProperties.json index 22df0dac..cae4d3c7 100644 --- a/tests/draft2020-12/additionalProperties.json +++ b/tests/draft2020-12/additionalProperties.json @@ -2,12 +2,7 @@ { "description": "additionalProperties being false does not allow other properties", - "specification":{ - "jsonschema-core": { - "section": "10.3.2.3.", - "para": "1" - } - }, + "specification": [ { "core":"10.3.2.3", "quote": "The value of \"additionalProperties\" MUST be a valid JSON Schema. Boolean \"false\" forbids everything." } ], "schema": { "$schema": "https://json-schema.org/draft/2020-12/schema", "properties": {"foo": {}, "bar": {}}, @@ -49,11 +44,7 @@ }, { "description": "non-ASCII pattern with additionalProperties", - "specification":{ - "rfc8259":{ - "section": "4." - } - }, + "specification": [ { "core":"10.3.2.3"} ], "schema": { "$schema": "https://json-schema.org/draft/2020-12/schema", "patternProperties": {"^á": {}}, @@ -74,12 +65,7 @@ }, { "description": "additionalProperties with schema", - "specification":{ - "jsonschema-core": { - "section": "10.3.2.3.", - "para": "1" - } - }, + "specification": [ { "core":"10.3.2.3", "quote": "The value of \"additionalProperties\" MUST be a valid JSON Schema." } ], "schema": { "$schema": "https://json-schema.org/draft/2020-12/schema", "properties": {"foo": {}, "bar": {}}, @@ -104,8 +90,8 @@ ] }, { - "description": - "additionalProperties can exist by itself", + "description": "additionalProperties can exist by itself", + "specification": [ { "core":"10.3.2.3", "quote": "With no other applicator applying to object instances. This validates all the instance values irrespective of their property names" } ], "schema": { "$schema": "https://json-schema.org/draft/2020-12/schema", "additionalProperties": {"type": "boolean"} @@ -125,12 +111,7 @@ }, { "description": "additionalProperties are allowed by default", - "specification":{ - "jsonschema-core": { - "section": "10.3.2.3.", - "para": "5" - } - }, + "specification": [ { "core":"10.3.2.3", "quote": "Omitting this keyword has the same assertion behavior as an empty schema." } ], "schema": { "$schema": "https://json-schema.org/draft/2020-12/schema", "properties": {"foo": {}, "bar": {}} @@ -145,12 +126,7 @@ }, { "description": "additionalProperties does not look in applicators", - "specification":{ - "jsonschema-core": { - "section": "10.2.", - "para": "2" - } - }, + "specification":[ { "core": "10.2", "quote": "Subschemas of applicator keywords evaluate the instance completely independently such that the results of one such subschema MUST NOT impact the results of sibling subschemas." } ], "schema": { "$schema": "https://json-schema.org/draft/2020-12/schema", "allOf": [ @@ -168,12 +144,7 @@ }, { "description": "additionalProperties with null valued instance properties", - "specification":{ - "jsonschema-core": { - "section": "10.3.2.3.", - "para": "1" - } - }, + "specification": [ { "core":"10.3.2.3" } ], "schema": { "$schema": "https://json-schema.org/draft/2020-12/schema", "additionalProperties": { From 51fc69cd7d97b47ab6685c5a2bd874174e48ef18 Mon Sep 17 00:00:00 2001 From: Suprith KG Date: Sat, 6 Apr 2024 02:03:09 +0530 Subject: [PATCH 6/6] meta data and property names constraints added, additional Items: string --- test-schema.json | 59 +++++++++++++++++++++++++++++++++++++++++------- 1 file changed, 51 insertions(+), 8 deletions(-) diff --git a/test-schema.json b/test-schema.json index 5de3917d..0087c5e3 100644 --- a/test-schema.json +++ b/test-schema.json @@ -33,19 +33,62 @@ "type": "array", "minItems": 1, + "uniqueItems": true, "items":{ "properties": { - "core": { "pattern": "^[0-9a-zA-Z]+(\\.[0-9a-zA-Z]+)*$", "type":"string" }, - "validation": { "pattern": "^[0-9a-zA-Z]+(\\.[0-9a-zA-Z]+)*$", "type":"string" }, - "ecma262": { "pattern": "^[0-9a-zA-Z]+(\\.[0-9a-zA-Z]+)*$", "type":"string" }, - "perl5": { "type":"string" }, - "quote": { "type":"string" } + "core": { + "description": "A section in official JSON Schema core drafts", + "url": "https://json-schema.org/specification-links", + "pattern": "^[0-9a-zA-Z]+(\\.[0-9a-zA-Z]+)*$", + "type":"string" + }, + "validation": { + "description": "A section in official JSON Schema validation drafts", + "url": "https://json-schema.org/specification-links", + "pattern": "^[0-9a-zA-Z]+(\\.[0-9a-zA-Z]+)*$", + "type":"string" + }, + "ecma262": { + "description": "A section in official ECMA 262 specification for defining regular expressions", + "url": "https://262.ecma-international.org/", + "pattern": "^[0-9a-zA-Z]+(\\.[0-9a-zA-Z]+)*$", + "type":"string" + }, + "perl5": { + "description": "A section name in Perl documentation for defining regular expressions", + "url": "https://perldoc.perl.org/perlre", + "type":"string" + }, + "quote": { + "description": "Quote describing the test case", + "type":"string" + } }, "patternProperties": { - "^rfc\\d+$": { "pattern": "^[0-9a-zA-Z]+.([0-9a-zA-Z]+)*$", "type":"string" } + "^rfc\\d+$": { + "description": "A section in official RFC for the given rfc number", + "url": "https://www.rfc-editor.org/", + "pattern": "^[0-9a-zA-Z]+(\\.[0-9a-zA-Z]+)*$", + "type":"string" + }, + "^iso\\d+$": { + "description": "A section in official ISO for the given iso number", + "pattern": "^[0-9a-zA-Z]+(\\.[0-9a-zA-Z]+)*$", + "type": "string" + } }, - "additionalProperties": false, - "minProperties": 1 + "additionalProperties": { "type": "string" }, + "minProperties": 1, + "propertyNames": { + "oneOf": [ + { + "pattern": "^((iso)|(rfc))[0-9]+$" + }, + { + "enum": [ "core", "validation", "ecma262", "perl5", "quote" ] + } + ] + } } } },