From b24fae28923ba15e9199fc42c6976b2dd4125b46 Mon Sep 17 00:00:00 2001 From: Philipp Dunkel Date: Mon, 26 Dec 2016 00:51:21 +0000 Subject: [PATCH] When $ref is present other keywords should be ignored --- tests/draft3/ref.json | 33 +++++++++++++++++++++++++++++++++ tests/draft4/ref.json | 33 +++++++++++++++++++++++++++++++++ 2 files changed, 66 insertions(+) diff --git a/tests/draft3/ref.json b/tests/draft3/ref.json index 903ecb6b..31414ad6 100644 --- a/tests/draft3/ref.json +++ b/tests/draft3/ref.json @@ -140,6 +140,39 @@ } ] }, + { + "description": "ref overrides any sibling keywords", + "schema": { + "definitions": { + "reffed": { + "type": "array" + } + }, + "properties": { + "foo": { + "$ref": "#/definitions/reffed", + "maxItems": 2 + } + } + }, + "tests": [ + { + "description": "remote ref valid", + "data": { "foo": [] }, + "valid": true + }, + { + "description": "remote ref valid, maxItems ignored", + "data": { "foo": [ 1, 2, 3] }, + "valid": true + }, + { + "description": "ref invalid", + "data": { "foo": "string" }, + "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 7e805522..fc286bb9 100644 --- a/tests/draft4/ref.json +++ b/tests/draft4/ref.json @@ -140,6 +140,39 @@ } ] }, + { + "description": "ref overrides any sibling keywords", + "schema": { + "definitions": { + "reffed": { + "type": "array" + } + }, + "properties": { + "foo": { + "$ref": "#/definitions/reffed", + "maxItems": 2 + } + } + }, + "tests": [ + { + "description": "ref valid", + "data": { "foo": [] }, + "valid": true + }, + { + "description": "ref valid, maxItems ignored", + "data": { "foo": [ 1, 2, 3] }, + "valid": true + }, + { + "description": "ref invalid", + "data": { "foo": "string" }, + "valid": false + } + ] + }, { "description": "remote ref, containing refs itself", "schema": {"$ref": "http://json-schema.org/draft-04/schema#"},