From 452b5f8f4f7e1d99657d453431490f516c8fe4af Mon Sep 17 00:00:00 2001 From: "Ryan J. Miller" Date: Tue, 9 Jun 2020 13:36:50 -0400 Subject: [PATCH 1/2] Test property named $ref, containing an actual $ref --- tests/draft2019-09/ref.json | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/tests/draft2019-09/ref.json b/tests/draft2019-09/ref.json index a756eb0d..97f70544 100644 --- a/tests/draft2019-09/ref.json +++ b/tests/draft2019-09/ref.json @@ -211,6 +211,31 @@ } ] }, + { + "description": "property named $ref, containing an actual $ref", + "schema": { + "properties": { + "$ref": {"$ref": "#/$defs/is-string"} + }, + "$defs": { + "is-string": { + "type": "string" + } + } + }, + "tests": [ + { + "description": "property named $ref valid", + "data": {"$ref": "a"}, + "valid": true + }, + { + "description": "property named $ref invalid", + "data": {"$ref": 2}, + "valid": false + } + ] + }, { "description": "$ref to boolean schema true", "schema": { From d595dbf9d29e8a211152f5555ee889f5d08ce308 Mon Sep 17 00:00:00 2001 From: "Ryan J. Miller" Date: Thu, 11 Jun 2020 16:59:51 -0400 Subject: [PATCH 2/2] backport $ref cases, changing "$defs" to "definitions" --- tests/draft3/ref.json | 25 +++++++++++++++++++++++++ tests/draft4/ref.json | 25 +++++++++++++++++++++++++ tests/draft6/ref.json | 25 +++++++++++++++++++++++++ tests/draft7/ref.json | 25 +++++++++++++++++++++++++ 4 files changed, 100 insertions(+) diff --git a/tests/draft3/ref.json b/tests/draft3/ref.json index bd6b7778..74e963c4 100644 --- a/tests/draft3/ref.json +++ b/tests/draft3/ref.json @@ -173,6 +173,31 @@ } ] }, + { + "description": "property named $ref, containing an actual $ref", + "schema": { + "properties": { + "$ref": {"$ref": "#/definitions/is-string"} + }, + "definitions": { + "is-string": { + "type": "string" + } + } + }, + "tests": [ + { + "description": "property named $ref valid", + "data": {"$ref": "a"}, + "valid": true + }, + { + "description": "property named $ref invalid", + "data": {"$ref": 2}, + "valid": false + } + ] + }, { "description": "remote ref, containing refs itself", "schema": {"$ref": "http://json-schema.org/draft-03/schema#"}, diff --git a/tests/draft4/ref.json b/tests/draft4/ref.json index 895c880a..fc3e94be 100644 --- a/tests/draft4/ref.json +++ b/tests/draft4/ref.json @@ -209,6 +209,31 @@ } ] }, + { + "description": "property named $ref, containing an actual $ref", + "schema": { + "properties": { + "$ref": {"$ref": "#/definitions/is-string"} + }, + "definitions": { + "is-string": { + "type": "string" + } + } + }, + "tests": [ + { + "description": "property named $ref valid", + "data": {"$ref": "a"}, + "valid": true + }, + { + "description": "property named $ref invalid", + "data": {"$ref": 2}, + "valid": false + } + ] + }, { "description": "Recursive references between schemas", "schema": { diff --git a/tests/draft6/ref.json b/tests/draft6/ref.json index 6c29f228..8eaba56f 100644 --- a/tests/draft6/ref.json +++ b/tests/draft6/ref.json @@ -209,6 +209,31 @@ } ] }, + { + "description": "property named $ref, containing an actual $ref", + "schema": { + "properties": { + "$ref": {"$ref": "#/definitions/is-string"} + }, + "definitions": { + "is-string": { + "type": "string" + } + } + }, + "tests": [ + { + "description": "property named $ref valid", + "data": {"$ref": "a"}, + "valid": true + }, + { + "description": "property named $ref invalid", + "data": {"$ref": 2}, + "valid": false + } + ] + }, { "description": "$ref to boolean schema true", "schema": { diff --git a/tests/draft7/ref.json b/tests/draft7/ref.json index 9f1d81a7..5a8602ec 100644 --- a/tests/draft7/ref.json +++ b/tests/draft7/ref.json @@ -209,6 +209,31 @@ } ] }, + { + "description": "property named $ref, containing an actual $ref", + "schema": { + "properties": { + "$ref": {"$ref": "#/definitions/is-string"} + }, + "definitions": { + "is-string": { + "type": "string" + } + } + }, + "tests": [ + { + "description": "property named $ref valid", + "data": {"$ref": "a"}, + "valid": true + }, + { + "description": "property named $ref invalid", + "data": {"$ref": 2}, + "valid": false + } + ] + }, { "description": "$ref to boolean schema true", "schema": {