From 128146da5a55e21d5f93a7c81c7fac135de17051 Mon Sep 17 00:00:00 2001 From: Karen Etheridge Date: Thu, 22 Oct 2020 09:22:47 -0700 Subject: [PATCH] test that literal $refs are not evaluated as keywords An evaluator should not treat all $ref properties as if they were keywords -- such as literal properties inside "enum" and "const" --- tests/draft2019-09/ref.json | 23 +++++++++++++++++++++++ tests/draft3/ref.json | 23 +++++++++++++++++++++++ tests/draft4/ref.json | 23 +++++++++++++++++++++++ tests/draft6/ref.json | 23 +++++++++++++++++++++++ tests/draft7/ref.json | 23 +++++++++++++++++++++++ 5 files changed, 115 insertions(+) diff --git a/tests/draft2019-09/ref.json b/tests/draft2019-09/ref.json index 97f70544..2da81e35 100644 --- a/tests/draft2019-09/ref.json +++ b/tests/draft2019-09/ref.json @@ -407,5 +407,28 @@ "valid": false } ] + }, + { + "description": "naive replacement of $ref with its destination is not correct", + "schema": { + "$defs": { + "a_string": { "type": "string" } + }, + "enum": [ + { "$ref": "#/$defs/a_string" } + ] + }, + "tests": [ + { + "description": "do not evaluate the $ref inside the enum", + "data": "this is a string", + "valid": false + }, + { + "description": "match the enum exactly", + "data": { "$ref": "#/$defs/a_string" }, + "valid": true + } + ] } ] diff --git a/tests/draft3/ref.json b/tests/draft3/ref.json index 77b29476..ebdb236b 100644 --- a/tests/draft3/ref.json +++ b/tests/draft3/ref.json @@ -215,5 +215,28 @@ "valid": false } ] + }, + { + "description": "naive replacement of $ref with its destination is not correct", + "schema": { + "definitions": { + "a_string": { "type": "string" } + }, + "enum": [ + { "$ref": "#/definitions/a_string" } + ] + }, + "tests": [ + { + "description": "do not evaluate the $ref inside the enum", + "data": "this is a string", + "valid": false + }, + { + "description": "match the enum exactly", + "data": { "$ref": "#/definitions/a_string" }, + "valid": true + } + ] } ] diff --git a/tests/draft4/ref.json b/tests/draft4/ref.json index f88e9634..820839d7 100644 --- a/tests/draft4/ref.json +++ b/tests/draft4/ref.json @@ -434,5 +434,28 @@ "valid": false } ] + }, + { + "description": "naive replacement of $ref with its destination is not correct", + "schema": { + "definitions": { + "a_string": { "type": "string" } + }, + "enum": [ + { "$ref": "#/definitions/a_string" } + ] + }, + "tests": [ + { + "description": "do not evaluate the $ref inside the enum", + "data": "this is a string", + "valid": false + }, + { + "description": "match the enum exactly", + "data": { "$ref": "#/definitions/a_string" }, + "valid": true + } + ] } ] diff --git a/tests/draft6/ref.json b/tests/draft6/ref.json index 0138382c..3bb0efc3 100644 --- a/tests/draft6/ref.json +++ b/tests/draft6/ref.json @@ -466,5 +466,28 @@ "valid": false } ] + }, + { + "description": "naive replacement of $ref with its destination is not correct", + "schema": { + "definitions": { + "a_string": { "type": "string" } + }, + "enum": [ + { "$ref": "#/definitions/a_string" } + ] + }, + "tests": [ + { + "description": "do not evaluate the $ref inside the enum", + "data": "this is a string", + "valid": false + }, + { + "description": "match the enum exactly", + "data": { "$ref": "#/definitions/a_string" }, + "valid": true + } + ] } ] diff --git a/tests/draft7/ref.json b/tests/draft7/ref.json index 01ba9fa3..97ddf07c 100644 --- a/tests/draft7/ref.json +++ b/tests/draft7/ref.json @@ -466,5 +466,28 @@ "valid": false } ] + }, + { + "description": "naive replacement of $ref with its destination is not correct", + "schema": { + "definitions": { + "a_string": { "type": "string" } + }, + "enum": [ + { "$ref": "#/definitions/a_string" } + ] + }, + "tests": [ + { + "description": "do not evaluate the $ref inside the enum", + "data": "this is a string", + "valid": false + }, + { + "description": "match the enum exactly", + "data": { "$ref": "#/definitions/a_string" }, + "valid": true + } + ] } ]