Skip to content

Add $schema to 2019-09 and 2020-12, update README for draft configuration. #586

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 13 commits into from
Aug 31, 2022
Merged
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,8 @@ The precise steps described do not need to be followed exactly, but the results

To test a specific version:

* For 2019-09 and later published drafts, implementations that are able to detect the draft of each schema via `$schema` SHOULD be configured to do so
* For draft-07 and earlier, draft-next, and implementations unable to detect via `$schema`, implementations MUST be configured to expect the draft matching the test directory name
* Load any remote references [described below](additional-assumptions) and configure your implementation to retrieve them via their URIs
* Walk the filesystem tree for that version's subdirectory and for each `.json` file found:

Expand Down
17 changes: 15 additions & 2 deletions tests/draft2019-09/additionalItems.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
{
"description": "additionalItems as schema",
"schema": {
"$schema": "https://json-schema.org/draft/2019-09/schema",
"items": [{}],
"additionalItems": {"type": "integer"}
},
Expand All @@ -21,6 +22,7 @@
{
"description": "when items is schema, additionalItems does nothing",
"schema": {
"$schema": "https://json-schema.org/draft/2019-09/schema",
"items": {},
"additionalItems": false
},
Expand All @@ -35,6 +37,7 @@
{
"description": "array of items with no additionalItems permitted",
"schema": {
"$schema": "https://json-schema.org/draft/2019-09/schema",
"items": [{}, {}, {}],
"additionalItems": false
},
Expand Down Expand Up @@ -68,7 +71,10 @@
},
{
"description": "additionalItems as false without items",
"schema": {"additionalItems": false},
"schema": {
"$schema": "https://json-schema.org/draft/2019-09/schema",
"additionalItems": false
},
"tests": [
{
"description":
Expand All @@ -85,7 +91,10 @@
},
{
"description": "additionalItems are allowed by default",
"schema": {"items": [{"type": "integer"}]},
"schema": {
"$schema": "https://json-schema.org/draft/2019-09/schema",
"items": [{"type": "integer"}]
},
"tests": [
{
"description": "only the first item is validated",
Expand All @@ -97,6 +106,7 @@
{
"description": "additionalItems does not look in applicators, valid case",
"schema": {
"$schema": "https://json-schema.org/draft/2019-09/schema",
"allOf": [
{ "items": [ { "type": "integer" } ] }
],
Expand All @@ -113,6 +123,7 @@
{
"description": "additionalItems does not look in applicators, invalid case",
"schema": {
"$schema": "https://json-schema.org/draft/2019-09/schema",
"allOf": [
{ "items": [ { "type": "integer" }, { "type": "string" } ] }
],
Expand All @@ -130,6 +141,7 @@
{
"description": "items validation adjusts the starting index for additionalItems",
"schema": {
"$schema": "https://json-schema.org/draft/2019-09/schema",
"items": [ { "type": "string" } ],
"additionalItems": { "type": "integer" }
},
Expand All @@ -149,6 +161,7 @@
{
"description": "additionalItems with null instance elements",
"schema": {
"$schema": "https://json-schema.org/draft/2019-09/schema",
"additionalItems": {
"type": "null"
}
Expand Down
11 changes: 10 additions & 1 deletion tests/draft2019-09/additionalProperties.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"description":
"additionalProperties being false does not allow other properties",
"schema": {
"$schema": "https://json-schema.org/draft/2019-09/schema",
"properties": {"foo": {}, "bar": {}},
"patternProperties": { "^v": {} },
"additionalProperties": false
Expand Down Expand Up @@ -43,6 +44,7 @@
{
"description": "non-ASCII pattern with additionalProperties",
"schema": {
"$schema": "https://json-schema.org/draft/2019-09/schema",
"patternProperties": {"^á": {}},
"additionalProperties": false
},
Expand All @@ -62,6 +64,7 @@
{
"description": "additionalProperties with schema",
"schema": {
"$schema": "https://json-schema.org/draft/2019-09/schema",
"properties": {"foo": {}, "bar": {}},
"additionalProperties": {"type": "boolean"}
},
Expand All @@ -87,6 +90,7 @@
"description":
"additionalProperties can exist by itself",
"schema": {
"$schema": "https://json-schema.org/draft/2019-09/schema",
"additionalProperties": {"type": "boolean"}
},
"tests": [
Expand All @@ -104,7 +108,10 @@
},
{
"description": "additionalProperties are allowed by default",
"schema": {"properties": {"foo": {}, "bar": {}}},
"schema": {
"$schema": "https://json-schema.org/draft/2019-09/schema",
"properties": {"foo": {}, "bar": {}}
},
"tests": [
{
"description": "additional properties are allowed",
Expand All @@ -116,6 +123,7 @@
{
"description": "additionalProperties does not look in applicators",
"schema": {
"$schema": "https://json-schema.org/draft/2019-09/schema",
"allOf": [
{"properties": {"foo": {}}}
],
Expand All @@ -132,6 +140,7 @@
{
"description": "additionalProperties with null valued instance properties",
"schema": {
"$schema": "https://json-schema.org/draft/2019-09/schema",
"additionalProperties": {
"type": "null"
}
Expand Down
24 changes: 21 additions & 3 deletions tests/draft2019-09/allOf.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
{
"description": "allOf",
"schema": {
"$schema": "https://json-schema.org/draft/2019-09/schema",
"allOf": [
{
"properties": {
Expand Down Expand Up @@ -43,6 +44,7 @@
{
"description": "allOf with base schema",
"schema": {
"$schema": "https://json-schema.org/draft/2019-09/schema",
"properties": {"bar": {"type": "integer"}},
"required": ["bar"],
"allOf" : [
Expand Down Expand Up @@ -91,6 +93,7 @@
{
"description": "allOf simple types",
"schema": {
"$schema": "https://json-schema.org/draft/2019-09/schema",
"allOf": [
{"maximum": 30},
{"minimum": 20}
Expand All @@ -111,7 +114,10 @@
},
{
"description": "allOf with boolean schemas, all true",
"schema": {"allOf": [true, true]},
"schema": {
"$schema": "https://json-schema.org/draft/2019-09/schema",
"allOf": [true, true]
},
"tests": [
{
"description": "any value is valid",
Expand All @@ -122,7 +128,10 @@
},
{
"description": "allOf with boolean schemas, some false",
"schema": {"allOf": [true, false]},
"schema": {
"$schema": "https://json-schema.org/draft/2019-09/schema",
"allOf": [true, false]
},
"tests": [
{
"description": "any value is invalid",
Expand All @@ -133,7 +142,10 @@
},
{
"description": "allOf with boolean schemas, all false",
"schema": {"allOf": [false, false]},
"schema": {
"$schema": "https://json-schema.org/draft/2019-09/schema",
"allOf": [false, false]
},
"tests": [
{
"description": "any value is invalid",
Expand All @@ -145,6 +157,7 @@
{
"description": "allOf with one empty schema",
"schema": {
"$schema": "https://json-schema.org/draft/2019-09/schema",
"allOf": [
{}
]
Expand All @@ -160,6 +173,7 @@
{
"description": "allOf with two empty schemas",
"schema": {
"$schema": "https://json-schema.org/draft/2019-09/schema",
"allOf": [
{},
{}
Expand All @@ -176,6 +190,7 @@
{
"description": "allOf with the first empty schema",
"schema": {
"$schema": "https://json-schema.org/draft/2019-09/schema",
"allOf": [
{},
{ "type": "number" }
Expand All @@ -197,6 +212,7 @@
{
"description": "allOf with the last empty schema",
"schema": {
"$schema": "https://json-schema.org/draft/2019-09/schema",
"allOf": [
{ "type": "number" },
{}
Expand All @@ -218,6 +234,7 @@
{
"description": "nested allOf, to check validation semantics",
"schema": {
"$schema": "https://json-schema.org/draft/2019-09/schema",
"allOf": [
{
"allOf": [
Expand All @@ -244,6 +261,7 @@
{
"description": "allOf combined with anyOf, oneOf",
"schema": {
"$schema": "https://json-schema.org/draft/2019-09/schema",
"allOf": [ { "multipleOf": 2 } ],
"anyOf": [ { "multipleOf": 3 } ],
"oneOf": [ { "multipleOf": 5 } ]
Expand Down
11 changes: 10 additions & 1 deletion tests/draft2019-09/anchor.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
{
"description": "Location-independent identifier",
"schema": {
"$schema": "https://json-schema.org/draft/2019-09/schema",
"$ref": "#foo",
"$defs": {
"A": {
Expand All @@ -26,6 +27,7 @@
{
"description": "Location-independent identifier with absolute URI",
"schema": {
"$schema": "https://json-schema.org/draft/2019-09/schema",
"$ref": "http://localhost:1234/bar#foo",
"$defs": {
"A": {
Expand All @@ -51,6 +53,7 @@
{
"description": "Location-independent identifier with base URI change in subschema",
"schema": {
"$schema": "https://json-schema.org/draft/2019-09/schema",
"$id": "http://localhost:1234/root",
"$ref": "http://localhost:1234/nested.json#foo",
"$defs": {
Expand Down Expand Up @@ -82,6 +85,7 @@
"description": "$anchor inside an enum is not a real identifier",
"comment": "the implementation must not be confused by an $anchor buried in the enum",
"schema": {
"$schema": "https://json-schema.org/draft/2019-09/schema",
"$defs": {
"anchor_in_enum": {
"enum": [
Expand Down Expand Up @@ -138,6 +142,7 @@
{
"description": "same $anchor with different base uri",
"schema": {
"$schema": "https://json-schema.org/draft/2019-09/schema",
"$id": "http://localhost:1234/foobar",
"$defs": {
"A": {
Expand Down Expand Up @@ -173,6 +178,7 @@
{
"description": "non-schema object containing an $anchor property",
"schema": {
"$schema": "https://json-schema.org/draft/2019-09/schema",
"$defs": {
"const_not_anchor": {
"const": {
Expand Down Expand Up @@ -204,7 +210,10 @@
{
"description": "invalid anchors",
"comment": "Section 8.2.3",
"schema": { "$ref": "https://json-schema.org/draft/2019-09/schema" },
"schema": {
"$schema": "https://json-schema.org/draft/2019-09/schema",
"$ref": "https://json-schema.org/draft/2019-09/schema"
},
"tests": [
{
"description": "MUST start with a letter (and not #)",
Expand Down
20 changes: 17 additions & 3 deletions tests/draft2019-09/anyOf.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
{
"description": "anyOf",
"schema": {
"$schema": "https://json-schema.org/draft/2019-09/schema",
"anyOf": [
{
"type": "integer"
Expand Down Expand Up @@ -37,6 +38,7 @@
{
"description": "anyOf with base schema",
"schema": {
"$schema": "https://json-schema.org/draft/2019-09/schema",
"type": "string",
"anyOf" : [
{
Expand Down Expand Up @@ -67,7 +69,10 @@
},
{
"description": "anyOf with boolean schemas, all true",
"schema": {"anyOf": [true, true]},
"schema": {
"$schema": "https://json-schema.org/draft/2019-09/schema",
"anyOf": [true, true]
},
"tests": [
{
"description": "any value is valid",
Expand All @@ -78,7 +83,10 @@
},
{
"description": "anyOf with boolean schemas, some true",
"schema": {"anyOf": [true, false]},
"schema": {
"$schema": "https://json-schema.org/draft/2019-09/schema",
"anyOf": [true, false]
},
"tests": [
{
"description": "any value is valid",
Expand All @@ -89,7 +97,10 @@
},
{
"description": "anyOf with boolean schemas, all false",
"schema": {"anyOf": [false, false]},
"schema": {
"$schema": "https://json-schema.org/draft/2019-09/schema",
"anyOf": [false, false]
},
"tests": [
{
"description": "any value is invalid",
Expand All @@ -101,6 +112,7 @@
{
"description": "anyOf complex types",
"schema": {
"$schema": "https://json-schema.org/draft/2019-09/schema",
"anyOf": [
{
"properties": {
Expand Down Expand Up @@ -142,6 +154,7 @@
{
"description": "anyOf with one empty schema",
"schema": {
"$schema": "https://json-schema.org/draft/2019-09/schema",
"anyOf": [
{ "type": "number" },
{}
Expand All @@ -163,6 +176,7 @@
{
"description": "nested anyOf, to check validation semantics",
"schema": {
"$schema": "https://json-schema.org/draft/2019-09/schema",
"anyOf": [
{
"anyOf": [
Expand Down
Loading