From 236b4b74beb0034b5c91de35b17da6258f9bf2dc Mon Sep 17 00:00:00 2001 From: Shawn Silverman Date: Fri, 24 Apr 2020 19:43:04 -0700 Subject: [PATCH] [301] Add tests for invalid "$anchor" syntax, remove wrapped "$ref"s --- tests/draft2019-09/anchor.json | 60 +++++++++++++++++++++++++++++----- 1 file changed, 51 insertions(+), 9 deletions(-) diff --git a/tests/draft2019-09/anchor.json b/tests/draft2019-09/anchor.json index 06b0ba4d..352b1ca0 100644 --- a/tests/draft2019-09/anchor.json +++ b/tests/draft2019-09/anchor.json @@ -2,9 +2,7 @@ { "description": "Location-independent identifier", "schema": { - "allOf": [{ - "$ref": "#foo" - }], + "$ref": "#foo", "$defs": { "A": { "$anchor": "foo", @@ -28,9 +26,7 @@ { "description": "Location-independent identifier with absolute URI", "schema": { - "allOf": [{ - "$ref": "http://localhost:1234/bar#foo" - }], + "$ref": "http://localhost:1234/bar#foo", "$defs": { "A": { "$id": "http://localhost:1234/bar", @@ -56,9 +52,7 @@ "description": "Location-independent identifier with base URI change in subschema", "schema": { "$id": "http://localhost:1234/root", - "allOf": [{ - "$ref": "http://localhost:1234/nested.json#foo" - }], + "$ref": "http://localhost:1234/nested.json#foo", "$defs": { "A": { "$id": "nested.json", @@ -83,5 +77,53 @@ "valid": false } ] + }, + { + "description": "Fragment syntax disallowed", + "schema": { + "$ref": "#foo", + "$defs": { + "A": { + "$anchor": "#foo", + "type": "integer" + } + } + }, + "tests": [ + { + "data": 1, + "description": "match", + "valid": false + }, + { + "data": "a", + "description": "mismatch", + "valid": false + } + ] + }, + { + "description": "Invalid characters disallowed", + "schema": { + "$ref": "#/a/b", + "$defs": { + "A": { + "$anchor": "/a/b", + "type": "integer" + } + } + }, + "tests": [ + { + "data": 1, + "description": "match", + "valid": false + }, + { + "data": "a", + "description": "mismatch", + "valid": false + } + ] } ]