diff --git a/README.md b/README.md index 5605bfb6..c6f17e2d 100644 --- a/README.md +++ b/README.md @@ -79,15 +79,13 @@ Here is a single *test case*, containing one or more tests: ### Subdirectories Within Each Version directory -There is currently only one additional subdirectory that may exist within each specification version test directory. +A specification version test directory may contain one or more subdirectories. -This is: +These are: -1. `optional/`: Contains tests that are considered optional. +1. `optional/`: Contains tests that are considered optional. Note that this subdirectory currently conflates many reasons why a test may be optional -- it may be because tests within a particular file are indeed not required by the specification but still potentially useful to an implementer, or it may be because tests within it only apply to programming languages with particular functionality (in which case they are not truly optional in such a language). In the future this directory structure will be made richer to reflect these differences more clearly. -Note, the `optional/` subdirectory today conflates many reasons why a test may be optional -- it may be because tests within a particular file are indeed not required by the specification but still potentially useful to an implementer, or it may be because tests within it only apply to programming languages with particular functionality (in -which case they are not truly optional in such a language). -In the future this directory structure will be made richer to reflect these differences more clearly. +2. `proposals/`: Contains a subfolder for each active proposal to the specification. If the proposal is a keyword (generally the case), then the subfolder will bear the name of that keyword. Inside the proposal subfolder is a series of test files that would contain amendments to the required test suite should the proposal be incorporated into the specification. These test should be considered volitile while the proposal is in development, however implementations claiming to support the proposal are expected to pass its tests. ## Using the Suite to Test a Validator Implementation diff --git a/tests/v1/additionalProperties.json b/tests/v1/additionalProperties.json index 301b4552..a776e818 100644 --- a/tests/v1/additionalProperties.json +++ b/tests/v1/additionalProperties.json @@ -177,41 +177,6 @@ } ] }, - { - "description": "propertyDependencies with additionalProperties", - "schema": { - "$schema": "https://json-schema.org/v1", - "properties" : {"foo2" : {}}, - "propertyDependencies": { - "foo" : {}, - "foo2": { - "bar": { - "properties": { - "buz": {} - } - } - } - }, - "additionalProperties": false - }, - "tests": [ - { - "description": "additionalProperties doesn't consider propertyDependencies properties" , - "data": {"foo": ""}, - "valid": false - }, - { - "description": "additionalProperties can't see buz even when foo2 is present", - "data": {"foo2": "bar", "buz": ""}, - "valid": false - }, - { - "description": "additionalProperties can't see buz", - "data": {"buz": ""}, - "valid": false - } - ] - }, { "description": "dependentSchemas with additionalProperties", "schema": { diff --git a/tests/v1/dynamicRef.json b/tests/v1/dynamicRef.json index 1609c6ec..a50c2cf6 100644 --- a/tests/v1/dynamicRef.json +++ b/tests/v1/dynamicRef.json @@ -123,83 +123,6 @@ } ] }, - { - "description": "multiple dynamic paths to the $dynamicRef keyword", - "schema": { - "$schema": "https://json-schema.org/v1", - "$id": "https://test.json-schema.org/dynamic-ref-with-multiple-paths/main", - "propertyDependencies": { - "kindOfList": { - "numbers": { "$ref": "numberList" }, - "strings": { "$ref": "stringList" } - } - }, - "$defs": { - "genericList": { - "$id": "genericList", - "properties": { - "list": { - "items": { "$dynamicRef": "#itemType" } - } - } - }, - "numberList": { - "$id": "numberList", - "$defs": { - "itemType": { - "$dynamicAnchor": "itemType", - "type": "number" - } - }, - "$ref": "genericList" - }, - "stringList": { - "$id": "stringList", - "$defs": { - "itemType": { - "$dynamicAnchor": "itemType", - "type": "string" - } - }, - "$ref": "genericList" - } - } - }, - "tests": [ - { - "description": "number list with number values", - "data": { - "kindOfList": "numbers", - "list": [1.1] - }, - "valid": true - }, - { - "description": "number list with string values", - "data": { - "kindOfList": "numbers", - "list": ["foo"] - }, - "valid": false - }, - { - "description": "string list with number values", - "data": { - "kindOfList": "strings", - "list": [1.1] - }, - "valid": false - }, - { - "description": "string list with string values", - "data": { - "kindOfList": "strings", - "list": ["foo"] - }, - "valid": true - } - ] - }, { "description": "after leaving a dynamic scope, it is not used by a $dynamicRef", "schema": { @@ -440,86 +363,6 @@ } ] }, - { - "description": "$dynamicAnchor inside propertyDependencies", - "schema": { - "$schema": "https://json-schema.org/v1", - "$id": "http://localhost:1234/v1/dynamicanchor-in-propertydependencies.json", - "$defs": { - "inner": { - "$id": "inner", - "$dynamicAnchor": "foo", - "type": "object", - "properties": { - "expectedTypes": { - "type": "string" - } - }, - "additionalProperties": { - "$dynamicRef": "#foo" - } - } - }, - "propertyDependencies": { - "expectedTypes": { - "strings": { - "$id": "east", - "$ref": "inner", - "$defs": { - "foo": { - "$dynamicAnchor": "foo", - "type": "string" - } - } - }, - "integers": { - "$id": "west", - "$ref": "inner", - "$defs": { - "foo": { - "$dynamicAnchor": "foo", - "type": "integer" - } - } - } - } - } - }, - "tests": [ - { - "description": "expected strings - additional property as string is valid", - "data": { - "expectedTypes": "strings", - "anotherProperty": "also a string" - }, - "valid": true - }, - { - "description": "expected strings - additional property as not string is invalid", - "data": { - "expectedTypes": "strings", - "anotherProperty": 42 - }, - "valid": false - }, - { - "description": "expected integers - additional property as integer is valid", - "data": { - "expectedTypes": "integers", - "anotherProperty": 42 - }, - "valid": true - }, - { - "description": "expected integers - additional property as not integer is invalid", - "data": { - "expectedTypes": "integers", - "anotherProperty": "a string" - }, - "valid": false - } - ] - }, { "description": "$ref to $dynamicRef finds detached $dynamicAnchor", "schema": { diff --git a/tests/v1/proposals/README.md b/tests/v1/proposals/README.md new file mode 100644 index 00000000..4cb65322 --- /dev/null +++ b/tests/v1/proposals/README.md @@ -0,0 +1,10 @@ +# JSON Schema Proposals Tests + +The subfolders herein represent tests for each active proposal to the specification. If the proposal is a keyword (generally the case), then the subfolder will bear the name of that keyword. Inside the proposal subfolder is a series of test files that would contain amendments to the required test suite should the proposal be incorporated into the specification. These test should be considered volitile while the proposal is in development, however implementations claiming to support the proposal are expected to pass its tests. + +> [!IMPORTANT] +> This folder is NOT intended for proposed additions to the test suite or the specification. + +Proposals to the test suite can be made by [opening an issue](https://github.com/json-schema-org/JSON-Schema-Test-Suite/issues/new) in this repository. + +Proposals to the specification should be made by following the process defined by our [Feature Life Cycle](https://github.com/json-schema-org/json-schema-spec/blob/main/PROCESS.md#feature-life-cycle). \ No newline at end of file diff --git a/tests/v1/proposals/propertyDependencies/additionalProperties.json b/tests/v1/proposals/propertyDependencies/additionalProperties.json new file mode 100644 index 00000000..8e61c282 --- /dev/null +++ b/tests/v1/proposals/propertyDependencies/additionalProperties.json @@ -0,0 +1,37 @@ +[ + { + "description": "propertyDependencies with additionalProperties", + "schema": { + "$schema": "https://json-schema.org/v1", + "properties" : {"foo2" : {}}, + "propertyDependencies": { + "foo" : {}, + "foo2": { + "bar": { + "properties": { + "buz": {} + } + } + } + }, + "additionalProperties": false + }, + "tests": [ + { + "description": "additionalProperties doesn't consider propertyDependencies properties" , + "data": {"foo": ""}, + "valid": false + }, + { + "description": "additionalProperties can't see buz even when foo2 is present", + "data": {"foo2": "bar", "buz": ""}, + "valid": false + }, + { + "description": "additionalProperties can't see buz", + "data": {"buz": ""}, + "valid": false + } + ] + } +] diff --git a/tests/v1/proposals/propertyDependencies/dynamicRef.json b/tests/v1/proposals/propertyDependencies/dynamicRef.json new file mode 100644 index 00000000..f2ec504e --- /dev/null +++ b/tests/v1/proposals/propertyDependencies/dynamicRef.json @@ -0,0 +1,159 @@ +[ + { + "description": "multiple dynamic paths to the $dynamicRef keyword", + "schema": { + "$schema": "https://json-schema.org/v1", + "$id": "https://test.json-schema.org/dynamic-ref-with-multiple-paths/main", + "propertyDependencies": { + "kindOfList": { + "numbers": { "$ref": "numberList" }, + "strings": { "$ref": "stringList" } + } + }, + "$defs": { + "genericList": { + "$id": "genericList", + "properties": { + "list": { + "items": { "$dynamicRef": "#itemType" } + } + } + }, + "numberList": { + "$id": "numberList", + "$defs": { + "itemType": { + "$dynamicAnchor": "itemType", + "type": "number" + } + }, + "$ref": "genericList" + }, + "stringList": { + "$id": "stringList", + "$defs": { + "itemType": { + "$dynamicAnchor": "itemType", + "type": "string" + } + }, + "$ref": "genericList" + } + } + }, + "tests": [ + { + "description": "number list with number values", + "data": { + "kindOfList": "numbers", + "list": [1.1] + }, + "valid": true + }, + { + "description": "number list with string values", + "data": { + "kindOfList": "numbers", + "list": ["foo"] + }, + "valid": false + }, + { + "description": "string list with number values", + "data": { + "kindOfList": "strings", + "list": [1.1] + }, + "valid": false + }, + { + "description": "string list with string values", + "data": { + "kindOfList": "strings", + "list": ["foo"] + }, + "valid": true + } + ] + }, + { + "description": "$dynamicAnchor inside propertyDependencies", + "schema": { + "$schema": "https://json-schema.org/v1", + "$id": "http://localhost:1234/v1/dynamicanchor-in-propertydependencies.json", + "$defs": { + "inner": { + "$id": "inner", + "$dynamicAnchor": "foo", + "type": "object", + "properties": { + "expectedTypes": { + "type": "string" + } + }, + "additionalProperties": { + "$dynamicRef": "#foo" + } + } + }, + "propertyDependencies": { + "expectedTypes": { + "strings": { + "$id": "east", + "$ref": "inner", + "$defs": { + "foo": { + "$dynamicAnchor": "foo", + "type": "string" + } + } + }, + "integers": { + "$id": "west", + "$ref": "inner", + "$defs": { + "foo": { + "$dynamicAnchor": "foo", + "type": "integer" + } + } + } + } + } + }, + "tests": [ + { + "description": "expected strings - additional property as string is valid", + "data": { + "expectedTypes": "strings", + "anotherProperty": "also a string" + }, + "valid": true + }, + { + "description": "expected strings - additional property as not string is invalid", + "data": { + "expectedTypes": "strings", + "anotherProperty": 42 + }, + "valid": false + }, + { + "description": "expected integers - additional property as integer is valid", + "data": { + "expectedTypes": "integers", + "anotherProperty": 42 + }, + "valid": true + }, + { + "description": "expected integers - additional property as not integer is invalid", + "data": { + "expectedTypes": "integers", + "anotherProperty": "a string" + }, + "valid": false + } + ] + } +] diff --git a/tests/v1/propertyDependencies.json b/tests/v1/proposals/propertyDependencies/propertyDependencies.json similarity index 100% rename from tests/v1/propertyDependencies.json rename to tests/v1/proposals/propertyDependencies/propertyDependencies.json diff --git a/tests/v1/proposals/propertyDependencies/unevaluatedProperties.json b/tests/v1/proposals/propertyDependencies/unevaluatedProperties.json new file mode 100644 index 00000000..d5d58a1d --- /dev/null +++ b/tests/v1/proposals/propertyDependencies/unevaluatedProperties.json @@ -0,0 +1,84 @@ +[ + { + "description": "unevaluatedProperties can see inside propertyDependencies", + "schema": { + "$schema": "https://json-schema.org/v1", + "properties": { + "foo": { + "type": "string" + } + }, + "propertyDependencies": { + "foo": { + "foo1": { + "properties": { + "bar": true + } + } + } + }, + "unevaluatedProperties": false + }, + "tests": [ + { + "description": "allows bar if foo = foo1", + "data": { + "foo": "foo1", + "bar": 42 + }, + "valid": true + }, + { + "description": "disallows bar if foo != foo1", + "data": { + "foo": "foo2", + "bar": 42 + }, + "valid": false + }, + { + "description": "disallows bar if foo is absent", + "data": { + "bar": 42 + }, + "valid": false + } + ] + }, + { + "description": "propertyDependencies with unevaluatedProperties" , + "schema" : { + "$schema": "https://json-schema.org/v1", + "properties" : {"foo2" : {}}, + "propertyDependencies": { + "foo" : {}, + "foo2": { + "bar": { + "properties": { + "buz": {} + } + } + } + }, + "unevaluatedProperties": false + }, + + "tests": [ + { + "description": "unevaluatedProperties doesn't consider propertyDependencies" , + "data": {"foo": "bar"}, + "valid": false + }, + { + "description": "unevaluatedProperties sees buz when foo2 is present", + "data": {"foo2": "bar", "buz": ""}, + "valid": true + }, + { + "description": "unevaluatedProperties doesn't see buz when foo2 is absent", + "data": {"buz": ""}, + "valid": false + } + ] + } +] diff --git a/tests/v1/unevaluatedProperties.json b/tests/v1/unevaluatedProperties.json index f1d40fdc..e8893be7 100644 --- a/tests/v1/unevaluatedProperties.json +++ b/tests/v1/unevaluatedProperties.json @@ -1504,52 +1504,6 @@ } ] }, - { - "description": "unevaluatedProperties can see inside propertyDependencies", - "schema": { - "$schema": "https://json-schema.org/v1", - "properties": { - "foo": { - "type": "string" - } - }, - "propertyDependencies": { - "foo": { - "foo1": { - "properties": { - "bar": true - } - } - } - }, - "unevaluatedProperties": false - }, - "tests": [ - { - "description": "allows bar if foo = foo1", - "data": { - "foo": "foo1", - "bar": 42 - }, - "valid": true - }, - { - "description": "disallows bar if foo != foo1", - "data": { - "foo": "foo2", - "bar": 42 - }, - "valid": false - }, - { - "description": "disallows bar if foo is absent", - "data": { - "bar": 42 - }, - "valid": false - } - ] - }, { "description": "unevaluatedProperties not affected by propertyNames", "schema": { @@ -1602,42 +1556,6 @@ } ] }, - { - "description": "propertyDependencies with unevaluatedProperties" , - "schema" : { - "$schema": "https://json-schema.org/v1", - "properties" : {"foo2" : {}}, - "propertyDependencies": { - "foo" : {}, - "foo2": { - "bar": { - "properties": { - "buz": {} - } - } - } - }, - "unevaluatedProperties": false - }, - - "tests": [ - { - "description": "unevaluatedProperties doesn't consider propertyDependencies" , - "data": {"foo": "bar"}, - "valid": false - }, - { - "description": "unevaluatedProperties sees buz when foo2 is present", - "data": {"foo2": "bar", "buz": ""}, - "valid": true - }, - { - "description": "unevaluatedProperties doesn't see buz when foo2 is absent", - "data": {"buz": ""}, - "valid": false - } - ] - }, { "description": "dependentSchemas with unevaluatedProperties", "schema": {