From eadc41672d144b7ad81c343efd0a834b1e84eac3 Mon Sep 17 00:00:00 2001 From: Matthew Adams Date: Sat, 9 Sep 2023 15:36:44 +0100 Subject: [PATCH 1/2] Added tests to encoded refs to unknown keywords. --- .../optional/refOfUnknownKeyword.json | 48 ++++++++++++++++++- .../optional/refOfUnknownKeyword.json | 48 ++++++++++++++++++- .../optional/refOfUnknownKeyword.json | 44 +++++++++++++++++ 3 files changed, 136 insertions(+), 4 deletions(-) diff --git a/tests/draft-next/optional/refOfUnknownKeyword.json b/tests/draft-next/optional/refOfUnknownKeyword.json index 489701cd..a247f9f4 100644 --- a/tests/draft-next/optional/refOfUnknownKeyword.json +++ b/tests/draft-next/optional/refOfUnknownKeyword.json @@ -2,7 +2,7 @@ { "description": "reference of a root arbitrary keyword ", "schema": { - "$schema": "https://json-schema.org/draft/next/schema", + "$schema": "https://json-schema.org/draft/2020-12/schema", "unknown-keyword": {"type": "integer"}, "properties": { "bar": {"$ref": "#/unknown-keyword"} @@ -21,10 +21,32 @@ } ] }, + { + "description": "reference of a root arbitrary keyword with encoded ref", + "schema": { + "$schema": "https://json-schema.org/draft/2020-12/schema", + "unknown/keyword": {"type": "integer"}, + "properties": { + "bar": {"$ref": "#/unknown~1keyword"} + } + }, + "tests": [ + { + "description": "match", + "data": {"bar": 3}, + "valid": true + }, + { + "description": "mismatch", + "data": {"bar": true}, + "valid": false + } + ] + }, { "description": "reference of an arbitrary keyword of a sub-schema", "schema": { - "$schema": "https://json-schema.org/draft/next/schema", + "$schema": "https://json-schema.org/draft/2020-12/schema", "properties": { "foo": {"unknown-keyword": {"type": "integer"}}, "bar": {"$ref": "#/properties/foo/unknown-keyword"} @@ -42,5 +64,27 @@ "valid": false } ] + }, + { + "description": "reference of an arbitrary keyword of a sub-schema with encoded ref", + "schema": { + "$schema": "https://json-schema.org/draft/2020-12/schema", + "properties": { + "foo": {"unknown/keyword": {"type": "integer"}}, + "bar": {"$ref": "#/properties/foo/unknown~1keyword"} + } + }, + "tests": [ + { + "description": "match", + "data": {"bar": 3}, + "valid": true + }, + { + "description": "mismatch", + "data": {"bar": true}, + "valid": false + } + ] } ] diff --git a/tests/draft2019-09/optional/refOfUnknownKeyword.json b/tests/draft2019-09/optional/refOfUnknownKeyword.json index eee1c33e..a247f9f4 100644 --- a/tests/draft2019-09/optional/refOfUnknownKeyword.json +++ b/tests/draft2019-09/optional/refOfUnknownKeyword.json @@ -2,7 +2,7 @@ { "description": "reference of a root arbitrary keyword ", "schema": { - "$schema": "https://json-schema.org/draft/2019-09/schema", + "$schema": "https://json-schema.org/draft/2020-12/schema", "unknown-keyword": {"type": "integer"}, "properties": { "bar": {"$ref": "#/unknown-keyword"} @@ -21,10 +21,32 @@ } ] }, + { + "description": "reference of a root arbitrary keyword with encoded ref", + "schema": { + "$schema": "https://json-schema.org/draft/2020-12/schema", + "unknown/keyword": {"type": "integer"}, + "properties": { + "bar": {"$ref": "#/unknown~1keyword"} + } + }, + "tests": [ + { + "description": "match", + "data": {"bar": 3}, + "valid": true + }, + { + "description": "mismatch", + "data": {"bar": true}, + "valid": false + } + ] + }, { "description": "reference of an arbitrary keyword of a sub-schema", "schema": { - "$schema": "https://json-schema.org/draft/2019-09/schema", + "$schema": "https://json-schema.org/draft/2020-12/schema", "properties": { "foo": {"unknown-keyword": {"type": "integer"}}, "bar": {"$ref": "#/properties/foo/unknown-keyword"} @@ -42,5 +64,27 @@ "valid": false } ] + }, + { + "description": "reference of an arbitrary keyword of a sub-schema with encoded ref", + "schema": { + "$schema": "https://json-schema.org/draft/2020-12/schema", + "properties": { + "foo": {"unknown/keyword": {"type": "integer"}}, + "bar": {"$ref": "#/properties/foo/unknown~1keyword"} + } + }, + "tests": [ + { + "description": "match", + "data": {"bar": 3}, + "valid": true + }, + { + "description": "mismatch", + "data": {"bar": true}, + "valid": false + } + ] } ] diff --git a/tests/draft2020-12/optional/refOfUnknownKeyword.json b/tests/draft2020-12/optional/refOfUnknownKeyword.json index f91c1888..a247f9f4 100644 --- a/tests/draft2020-12/optional/refOfUnknownKeyword.json +++ b/tests/draft2020-12/optional/refOfUnknownKeyword.json @@ -21,6 +21,28 @@ } ] }, + { + "description": "reference of a root arbitrary keyword with encoded ref", + "schema": { + "$schema": "https://json-schema.org/draft/2020-12/schema", + "unknown/keyword": {"type": "integer"}, + "properties": { + "bar": {"$ref": "#/unknown~1keyword"} + } + }, + "tests": [ + { + "description": "match", + "data": {"bar": 3}, + "valid": true + }, + { + "description": "mismatch", + "data": {"bar": true}, + "valid": false + } + ] + }, { "description": "reference of an arbitrary keyword of a sub-schema", "schema": { @@ -42,5 +64,27 @@ "valid": false } ] + }, + { + "description": "reference of an arbitrary keyword of a sub-schema with encoded ref", + "schema": { + "$schema": "https://json-schema.org/draft/2020-12/schema", + "properties": { + "foo": {"unknown/keyword": {"type": "integer"}}, + "bar": {"$ref": "#/properties/foo/unknown~1keyword"} + } + }, + "tests": [ + { + "description": "match", + "data": {"bar": 3}, + "valid": true + }, + { + "description": "mismatch", + "data": {"bar": true}, + "valid": false + } + ] } ] From c82804f98e284c3d8eee068196c9d2d1165dbc64 Mon Sep 17 00:00:00 2001 From: Matthew Adams Date: Thu, 16 May 2024 08:53:10 +0100 Subject: [PATCH 2/2] Updated incorrect draft references --- tests/draft-next/optional/refOfUnknownKeyword.json | 6 +++--- tests/draft2019-09/optional/refOfUnknownKeyword.json | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/tests/draft-next/optional/refOfUnknownKeyword.json b/tests/draft-next/optional/refOfUnknownKeyword.json index 1aa0a758..50ee1fce 100644 --- a/tests/draft-next/optional/refOfUnknownKeyword.json +++ b/tests/draft-next/optional/refOfUnknownKeyword.json @@ -2,7 +2,7 @@ { "description": "reference of a root arbitrary keyword ", "schema": { - "$schema": "https://json-schema.org/draft/2020-12/schema", + "$schema": "https://json-schema.org/draft/next/schema", "unknown-keyword": {"type": "integer"}, "properties": { "bar": {"$ref": "#/unknown-keyword"} @@ -24,7 +24,7 @@ { "description": "reference of a root arbitrary keyword with encoded ref", "schema": { - "$schema": "https://json-schema.org/draft/2020-12/schema", + "$schema": "https://json-schema.org/draft/next/schema", "unknown/keyword": {"type": "integer"}, "properties": { "bar": {"$ref": "#/unknown~1keyword"} @@ -46,7 +46,7 @@ { "description": "reference of an arbitrary keyword of a sub-schema", "schema": { - "$schema": "https://json-schema.org/draft/2020-12/schema", + "$schema": "https://json-schema.org/draft/next/schema", "properties": { "foo": {"unknown-keyword": {"type": "integer"}}, "bar": {"$ref": "#/properties/foo/unknown-keyword"} diff --git a/tests/draft2019-09/optional/refOfUnknownKeyword.json b/tests/draft2019-09/optional/refOfUnknownKeyword.json index 3c787304..2db52308 100644 --- a/tests/draft2019-09/optional/refOfUnknownKeyword.json +++ b/tests/draft2019-09/optional/refOfUnknownKeyword.json @@ -2,7 +2,7 @@ { "description": "reference of a root arbitrary keyword ", "schema": { - "$schema": "https://json-schema.org/draft/2020-12/schema", + "$schema": "https://json-schema.org/draft/2019-09/schema", "unknown-keyword": {"type": "integer"}, "properties": { "bar": {"$ref": "#/unknown-keyword"} @@ -24,7 +24,7 @@ { "description": "reference of a root arbitrary keyword with encoded ref", "schema": { - "$schema": "https://json-schema.org/draft/2020-12/schema", + "$schema": "https://json-schema.org/draft/2019-09/schema", "unknown/keyword": {"type": "integer"}, "properties": { "bar": {"$ref": "#/unknown~1keyword"} @@ -46,7 +46,7 @@ { "description": "reference of an arbitrary keyword of a sub-schema", "schema": { - "$schema": "https://json-schema.org/draft/2020-12/schema", + "$schema": "https://json-schema.org/draft/2019-09/schema", "properties": { "foo": {"unknown-keyword": {"type": "integer"}}, "bar": {"$ref": "#/properties/foo/unknown-keyword"}