From e9db2e5813541b24d9c8737bc50bfb769059d12e Mon Sep 17 00:00:00 2001 From: willson-chen Date: Sat, 25 Jul 2020 09:31:19 +0800 Subject: [PATCH 1/3] subschema nested ref in remote ref --- remotes/baseUriChange/subSchemaNestedRef.json | 6 +++++ tests/draft2019-09/refRemote.json | 25 +++++++++++++++++++ tests/draft6/refRemote.json | 25 +++++++++++++++++++ tests/draft7/refRemote.json | 25 +++++++++++++++++++ 4 files changed, 81 insertions(+) create mode 100644 remotes/baseUriChange/subSchemaNestedRef.json diff --git a/remotes/baseUriChange/subSchemaNestedRef.json b/remotes/baseUriChange/subSchemaNestedRef.json new file mode 100644 index 00000000..87fda79b --- /dev/null +++ b/remotes/baseUriChange/subSchemaNestedRef.json @@ -0,0 +1,6 @@ +{ + "type": "object", + "properties": { + "hole": {"$ref": "integer.json"} + } +} diff --git a/tests/draft2019-09/refRemote.json b/tests/draft2019-09/refRemote.json index 0a5e4849..05b4b469 100644 --- a/tests/draft2019-09/refRemote.json +++ b/tests/draft2019-09/refRemote.json @@ -204,5 +204,30 @@ "valid": false } ] + }, + { + "description": "subschema nested ref in remote ref", + "schema": { + "$id": "http://localhost:1234/", + "properties": { + "name": {"$ref": "folder/subSchemaNestedRef.json"} + } + }, + "tests": [ + { + "description": "number is valid", + "data": { + "name": {"hole": 1} + }, + "valid": true + }, + { + "description": "string is invalid", + "data": { + "name": {"hole": "a"} + }, + "valid": false + } + ] } ] diff --git a/tests/draft6/refRemote.json b/tests/draft6/refRemote.json index 3b5a7fb7..ed04124a 100644 --- a/tests/draft6/refRemote.json +++ b/tests/draft6/refRemote.json @@ -210,5 +210,30 @@ "valid": false } ] + }, + { + "description": "subschema nested ref in remote ref", + "schema": { + "$id": "http://localhost:1234/", + "properties": { + "name": {"$ref": "folder/subSchemaNestedRef.json"} + } + }, + "tests": [ + { + "description": "number is valid", + "data": { + "name": {"hole": 1} + }, + "valid": true + }, + { + "description": "string is invalid", + "data": { + "name": {"hole": "a"} + }, + "valid": false + } + ] } ] diff --git a/tests/draft7/refRemote.json b/tests/draft7/refRemote.json index 3b5a7fb7..ed04124a 100644 --- a/tests/draft7/refRemote.json +++ b/tests/draft7/refRemote.json @@ -210,5 +210,30 @@ "valid": false } ] + }, + { + "description": "subschema nested ref in remote ref", + "schema": { + "$id": "http://localhost:1234/", + "properties": { + "name": {"$ref": "folder/subSchemaNestedRef.json"} + } + }, + "tests": [ + { + "description": "number is valid", + "data": { + "name": {"hole": 1} + }, + "valid": true + }, + { + "description": "string is invalid", + "data": { + "name": {"hole": "a"} + }, + "valid": false + } + ] } ] From 5be19e21cad991664c0936dbb2ba438df76d23be Mon Sep 17 00:00:00 2001 From: Julian Berman Date: Fri, 22 Jul 2022 16:02:49 +0300 Subject: [PATCH 2/3] Give the nested ref schema a clearer name, and fix refs to it. --- .../foo-ref-string.json} | 2 +- remotes/nested/string.json | 3 +++ tests/draft2019-09/refRemote.json | 18 +++++++++--------- tests/draft6/refRemote.json | 18 +++++++++--------- tests/draft7/refRemote.json | 18 +++++++++--------- 5 files changed, 31 insertions(+), 28 deletions(-) rename remotes/{baseUriChange/subSchemaNestedRef.json => nested/foo-ref-string.json} (55%) create mode 100644 remotes/nested/string.json diff --git a/remotes/baseUriChange/subSchemaNestedRef.json b/remotes/nested/foo-ref-string.json similarity index 55% rename from remotes/baseUriChange/subSchemaNestedRef.json rename to remotes/nested/foo-ref-string.json index 87fda79b..9cd2527e 100644 --- a/remotes/baseUriChange/subSchemaNestedRef.json +++ b/remotes/nested/foo-ref-string.json @@ -1,6 +1,6 @@ { "type": "object", "properties": { - "hole": {"$ref": "integer.json"} + "foo": {"$ref": "string.json"} } } diff --git a/remotes/nested/string.json b/remotes/nested/string.json new file mode 100644 index 00000000..c2d48c06 --- /dev/null +++ b/remotes/nested/string.json @@ -0,0 +1,3 @@ +{ + "type": "string" +} diff --git a/tests/draft2019-09/refRemote.json b/tests/draft2019-09/refRemote.json index 05b4b469..a8440396 100644 --- a/tests/draft2019-09/refRemote.json +++ b/tests/draft2019-09/refRemote.json @@ -206,27 +206,27 @@ ] }, { - "description": "subschema nested ref in remote ref", + "description": "retrieved nested refs resolve relative to their URI not $id", "schema": { - "$id": "http://localhost:1234/", + "$id": "http://localhost:1234/some-id", "properties": { - "name": {"$ref": "folder/subSchemaNestedRef.json"} + "name": {"$ref": "nested/foo-ref-string.json"} } }, "tests": [ { - "description": "number is valid", + "description": "number is invalid", "data": { - "name": {"hole": 1} + "name": {"foo": 1} }, - "valid": true + "valid": false }, { - "description": "string is invalid", + "description": "string is valid", "data": { - "name": {"hole": "a"} + "name": {"foo": "a"} }, - "valid": false + "valid": true } ] } diff --git a/tests/draft6/refRemote.json b/tests/draft6/refRemote.json index ed04124a..c2b20024 100644 --- a/tests/draft6/refRemote.json +++ b/tests/draft6/refRemote.json @@ -212,27 +212,27 @@ ] }, { - "description": "subschema nested ref in remote ref", + "description": "retrieved nested refs resolve relative to their URI not $id", "schema": { - "$id": "http://localhost:1234/", + "$id": "http://localhost:1234/some-id", "properties": { - "name": {"$ref": "folder/subSchemaNestedRef.json"} + "name": {"$ref": "nested/foo-ref-string.json"} } }, "tests": [ { - "description": "number is valid", + "description": "number is invalid", "data": { - "name": {"hole": 1} + "name": {"foo": 1} }, - "valid": true + "valid": false }, { - "description": "string is invalid", + "description": "string is valid", "data": { - "name": {"hole": "a"} + "name": {"foo": "a"} }, - "valid": false + "valid": true } ] } diff --git a/tests/draft7/refRemote.json b/tests/draft7/refRemote.json index ed04124a..c2b20024 100644 --- a/tests/draft7/refRemote.json +++ b/tests/draft7/refRemote.json @@ -212,27 +212,27 @@ ] }, { - "description": "subschema nested ref in remote ref", + "description": "retrieved nested refs resolve relative to their URI not $id", "schema": { - "$id": "http://localhost:1234/", + "$id": "http://localhost:1234/some-id", "properties": { - "name": {"$ref": "folder/subSchemaNestedRef.json"} + "name": {"$ref": "nested/foo-ref-string.json"} } }, "tests": [ { - "description": "number is valid", + "description": "number is invalid", "data": { - "name": {"hole": 1} + "name": {"foo": 1} }, - "valid": true + "valid": false }, { - "description": "string is invalid", + "description": "string is valid", "data": { - "name": {"hole": "a"} + "name": {"foo": "a"} }, - "valid": false + "valid": true } ] } From 13685a6cd282313c8eeb25a11f25185832b00feb Mon Sep 17 00:00:00 2001 From: Julian Berman Date: Fri, 22 Jul 2022 16:03:04 +0300 Subject: [PATCH 3/3] Forward port the nested ref test. --- tests/draft-next/refRemote.json | 25 +++++++++++++++++++++++++ tests/draft2020-12/refRemote.json | 25 +++++++++++++++++++++++++ 2 files changed, 50 insertions(+) diff --git a/tests/draft-next/refRemote.json b/tests/draft-next/refRemote.json index 0a5e4849..a8440396 100644 --- a/tests/draft-next/refRemote.json +++ b/tests/draft-next/refRemote.json @@ -204,5 +204,30 @@ "valid": false } ] + }, + { + "description": "retrieved nested refs resolve relative to their URI not $id", + "schema": { + "$id": "http://localhost:1234/some-id", + "properties": { + "name": {"$ref": "nested/foo-ref-string.json"} + } + }, + "tests": [ + { + "description": "number is invalid", + "data": { + "name": {"foo": 1} + }, + "valid": false + }, + { + "description": "string is valid", + "data": { + "name": {"foo": "a"} + }, + "valid": true + } + ] } ] diff --git a/tests/draft2020-12/refRemote.json b/tests/draft2020-12/refRemote.json index 0a5e4849..a8440396 100644 --- a/tests/draft2020-12/refRemote.json +++ b/tests/draft2020-12/refRemote.json @@ -204,5 +204,30 @@ "valid": false } ] + }, + { + "description": "retrieved nested refs resolve relative to their URI not $id", + "schema": { + "$id": "http://localhost:1234/some-id", + "properties": { + "name": {"$ref": "nested/foo-ref-string.json"} + } + }, + "tests": [ + { + "description": "number is invalid", + "data": { + "name": {"foo": 1} + }, + "valid": false + }, + { + "description": "string is valid", + "data": { + "name": {"foo": "a"} + }, + "valid": true + } + ] } ]