From b1813e6e9c5d9e7afcb0d35ed317ddf03c8872bb Mon Sep 17 00:00:00 2001 From: Iain Beeston Date: Fri, 30 Sep 2016 14:40:58 +0100 Subject: [PATCH] Made sure all $ref objects contain only a $ref property The IETF JSON Reference spec, section 3 (syntax) says the following: Any members other than "$ref" in a JSON Reference object SHALL be ignored. We have two groups of tests that have a $ref at the root level of the schema, referring to a definition that is also at the root level. According to the spec, a $ref object should not have any sibling properties. To make those JSON references valid, I've refactored those test cases to use a $ref object as a json schema property definition instead, which is valid. --- tests/draft3/ref.json | 10 +++++++--- tests/draft4/ref.json | 10 +++++++--- 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/tests/draft3/ref.json b/tests/draft3/ref.json index 903ecb6b..d7ce9d4f 100644 --- a/tests/draft3/ref.json +++ b/tests/draft3/ref.json @@ -125,17 +125,21 @@ "b": {"$ref": "#/definitions/a"}, "c": {"$ref": "#/definitions/b"} }, - "$ref": "#/definitions/c" + "properties": { + "foo": { + "$ref": "#/definitions/c" + } + } }, "tests": [ { "description": "nested ref valid", - "data": 5, + "data": {"foo": 5}, "valid": true }, { "description": "nested ref invalid", - "data": "a", + "data": {"foo": "a"}, "valid": false } ] diff --git a/tests/draft4/ref.json b/tests/draft4/ref.json index fe5aa901..69e94bbd 100644 --- a/tests/draft4/ref.json +++ b/tests/draft4/ref.json @@ -125,17 +125,21 @@ "b": {"$ref": "#/definitions/a"}, "c": {"$ref": "#/definitions/b"} }, - "$ref": "#/definitions/c" + "properties": { + "foo": { + "$ref": "#/definitions/c" + } + } }, "tests": [ { "description": "nested ref valid", - "data": 5, + "data": {"foo": 5}, "valid": true }, { "description": "nested ref invalid", - "data": "a", + "data": {"foo": "a"}, "valid": false } ]