jsonschema: resolve remote references
Support remote references. Most of the machinery was in place; we just had to define the right loader, copy files from the test repo, and download the meta-schema files from json-schema.org. Change-Id: Ib588200ef0fa483641b9b53f9904f53b39dc4b82 Reviewed-on: https://go-review.googlesource.com/c/tools/+/670795 LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Alan Donovan <adonovan@google.com>
This commit is contained in:
parent
1ae23e7031
commit
895b927ee8
23 changed files with 913 additions and 4 deletions
4
jsonschema/testdata/remotes/README.md
vendored
Normal file
4
jsonschema/testdata/remotes/README.md
vendored
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
# JSON Schema test suite: remote references
|
||||
|
||||
These files were copied from
|
||||
https://github.com/json-schema-org/JSON-Schema-Test-Suite/tree/83e866b46c9f9e7082fd51e83a61c5f2145a1ab7/remotes.
|
||||
5
jsonschema/testdata/remotes/different-id-ref-string.json
vendored
Normal file
5
jsonschema/testdata/remotes/different-id-ref-string.json
vendored
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
{
|
||||
"$id": "http://localhost:1234/real-id-ref-string.json",
|
||||
"$defs": {"bar": {"type": "string"}},
|
||||
"$ref": "#/$defs/bar"
|
||||
}
|
||||
4
jsonschema/testdata/remotes/draft2020-12/baseUriChange/folderInteger.json
vendored
Normal file
4
jsonschema/testdata/remotes/draft2020-12/baseUriChange/folderInteger.json
vendored
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
{
|
||||
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
||||
"type": "integer"
|
||||
}
|
||||
4
jsonschema/testdata/remotes/draft2020-12/baseUriChangeFolder/folderInteger.json
vendored
Normal file
4
jsonschema/testdata/remotes/draft2020-12/baseUriChangeFolder/folderInteger.json
vendored
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
{
|
||||
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
||||
"type": "integer"
|
||||
}
|
||||
4
jsonschema/testdata/remotes/draft2020-12/baseUriChangeFolderInSubschema/folderInteger.json
vendored
Normal file
4
jsonschema/testdata/remotes/draft2020-12/baseUriChangeFolderInSubschema/folderInteger.json
vendored
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
{
|
||||
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
||||
"type": "integer"
|
||||
}
|
||||
13
jsonschema/testdata/remotes/draft2020-12/detached-dynamicref.json
vendored
Normal file
13
jsonschema/testdata/remotes/draft2020-12/detached-dynamicref.json
vendored
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
{
|
||||
"$id": "http://localhost:1234/draft2020-12/detached-dynamicref.json",
|
||||
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
||||
"$defs": {
|
||||
"foo": {
|
||||
"$dynamicRef": "#detached"
|
||||
},
|
||||
"detached": {
|
||||
"$dynamicAnchor": "detached",
|
||||
"type": "integer"
|
||||
}
|
||||
}
|
||||
}
|
||||
13
jsonschema/testdata/remotes/draft2020-12/detached-ref.json
vendored
Normal file
13
jsonschema/testdata/remotes/draft2020-12/detached-ref.json
vendored
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
{
|
||||
"$id": "http://localhost:1234/draft2020-12/detached-ref.json",
|
||||
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
||||
"$defs": {
|
||||
"foo": {
|
||||
"$ref": "#detached"
|
||||
},
|
||||
"detached": {
|
||||
"$anchor": "detached",
|
||||
"type": "integer"
|
||||
}
|
||||
}
|
||||
}
|
||||
21
jsonschema/testdata/remotes/draft2020-12/extendible-dynamic-ref.json
vendored
Normal file
21
jsonschema/testdata/remotes/draft2020-12/extendible-dynamic-ref.json
vendored
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
{
|
||||
"description": "extendible array",
|
||||
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
||||
"$id": "http://localhost:1234/draft2020-12/extendible-dynamic-ref.json",
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"elements": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"$dynamicRef": "#elements"
|
||||
}
|
||||
}
|
||||
},
|
||||
"required": ["elements"],
|
||||
"additionalProperties": false,
|
||||
"$defs": {
|
||||
"elements": {
|
||||
"$dynamicAnchor": "elements"
|
||||
}
|
||||
}
|
||||
}
|
||||
13
jsonschema/testdata/remotes/draft2020-12/format-assertion-false.json
vendored
Normal file
13
jsonschema/testdata/remotes/draft2020-12/format-assertion-false.json
vendored
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
{
|
||||
"$id": "http://localhost:1234/draft2020-12/format-assertion-false.json",
|
||||
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
||||
"$vocabulary": {
|
||||
"https://json-schema.org/draft/2020-12/vocab/core": true,
|
||||
"https://json-schema.org/draft/2020-12/vocab/format-assertion": false
|
||||
},
|
||||
"$dynamicAnchor": "meta",
|
||||
"allOf": [
|
||||
{ "$ref": "https://json-schema.org/draft/2020-12/meta/core" },
|
||||
{ "$ref": "https://json-schema.org/draft/2020-12/meta/format-assertion" }
|
||||
]
|
||||
}
|
||||
13
jsonschema/testdata/remotes/draft2020-12/format-assertion-true.json
vendored
Normal file
13
jsonschema/testdata/remotes/draft2020-12/format-assertion-true.json
vendored
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
{
|
||||
"$id": "http://localhost:1234/draft2020-12/format-assertion-true.json",
|
||||
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
||||
"$vocabulary": {
|
||||
"https://json-schema.org/draft/2020-12/vocab/core": true,
|
||||
"https://json-schema.org/draft/2020-12/vocab/format-assertion": true
|
||||
},
|
||||
"$dynamicAnchor": "meta",
|
||||
"allOf": [
|
||||
{ "$ref": "https://json-schema.org/draft/2020-12/meta/core" },
|
||||
{ "$ref": "https://json-schema.org/draft/2020-12/meta/format-assertion" }
|
||||
]
|
||||
}
|
||||
4
jsonschema/testdata/remotes/draft2020-12/integer.json
vendored
Normal file
4
jsonschema/testdata/remotes/draft2020-12/integer.json
vendored
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
{
|
||||
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
||||
"type": "integer"
|
||||
}
|
||||
12
jsonschema/testdata/remotes/draft2020-12/locationIndependentIdentifier.json
vendored
Normal file
12
jsonschema/testdata/remotes/draft2020-12/locationIndependentIdentifier.json
vendored
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
{
|
||||
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
||||
"$defs": {
|
||||
"refToInteger": {
|
||||
"$ref": "#foo"
|
||||
},
|
||||
"A": {
|
||||
"$anchor": "foo",
|
||||
"type": "integer"
|
||||
}
|
||||
}
|
||||
}
|
||||
13
jsonschema/testdata/remotes/draft2020-12/metaschema-no-validation.json
vendored
Normal file
13
jsonschema/testdata/remotes/draft2020-12/metaschema-no-validation.json
vendored
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
{
|
||||
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
||||
"$id": "http://localhost:1234/draft2020-12/metaschema-no-validation.json",
|
||||
"$vocabulary": {
|
||||
"https://json-schema.org/draft/2020-12/vocab/applicator": true,
|
||||
"https://json-schema.org/draft/2020-12/vocab/core": true
|
||||
},
|
||||
"$dynamicAnchor": "meta",
|
||||
"allOf": [
|
||||
{ "$ref": "https://json-schema.org/draft/2020-12/meta/applicator" },
|
||||
{ "$ref": "https://json-schema.org/draft/2020-12/meta/core" }
|
||||
]
|
||||
}
|
||||
14
jsonschema/testdata/remotes/draft2020-12/metaschema-optional-vocabulary.json
vendored
Normal file
14
jsonschema/testdata/remotes/draft2020-12/metaschema-optional-vocabulary.json
vendored
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
{
|
||||
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
||||
"$id": "http://localhost:1234/draft2020-12/metaschema-optional-vocabulary.json",
|
||||
"$vocabulary": {
|
||||
"https://json-schema.org/draft/2020-12/vocab/validation": true,
|
||||
"https://json-schema.org/draft/2020-12/vocab/core": true,
|
||||
"http://localhost:1234/draft/2020-12/vocab/custom": false
|
||||
},
|
||||
"$dynamicAnchor": "meta",
|
||||
"allOf": [
|
||||
{ "$ref": "https://json-schema.org/draft/2020-12/meta/validation" },
|
||||
{ "$ref": "https://json-schema.org/draft/2020-12/meta/core" }
|
||||
]
|
||||
}
|
||||
16
jsonschema/testdata/remotes/draft2020-12/name-defs.json
vendored
Normal file
16
jsonschema/testdata/remotes/draft2020-12/name-defs.json
vendored
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
{
|
||||
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
||||
"$defs": {
|
||||
"orNull": {
|
||||
"anyOf": [
|
||||
{
|
||||
"type": "null"
|
||||
},
|
||||
{
|
||||
"$ref": "#"
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
"type": "string"
|
||||
}
|
||||
7
jsonschema/testdata/remotes/draft2020-12/nested/foo-ref-string.json
vendored
Normal file
7
jsonschema/testdata/remotes/draft2020-12/nested/foo-ref-string.json
vendored
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
{
|
||||
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"foo": {"$ref": "string.json"}
|
||||
}
|
||||
}
|
||||
4
jsonschema/testdata/remotes/draft2020-12/nested/string.json
vendored
Normal file
4
jsonschema/testdata/remotes/draft2020-12/nested/string.json
vendored
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
{
|
||||
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
||||
"type": "string"
|
||||
}
|
||||
7
jsonschema/testdata/remotes/draft2020-12/prefixItems.json
vendored
Normal file
7
jsonschema/testdata/remotes/draft2020-12/prefixItems.json
vendored
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
{
|
||||
"$id": "http://localhost:1234/draft2020-12/prefixItems.json",
|
||||
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
||||
"prefixItems": [
|
||||
{"type": "string"}
|
||||
]
|
||||
}
|
||||
12
jsonschema/testdata/remotes/draft2020-12/ref-and-defs.json
vendored
Normal file
12
jsonschema/testdata/remotes/draft2020-12/ref-and-defs.json
vendored
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
{
|
||||
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
||||
"$id": "http://localhost:1234/draft2020-12/ref-and-defs.json",
|
||||
"$defs": {
|
||||
"inner": {
|
||||
"properties": {
|
||||
"bar": { "type": "string" }
|
||||
}
|
||||
}
|
||||
},
|
||||
"$ref": "#/$defs/inner"
|
||||
}
|
||||
11
jsonschema/testdata/remotes/draft2020-12/subSchemas.json
vendored
Normal file
11
jsonschema/testdata/remotes/draft2020-12/subSchemas.json
vendored
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
{
|
||||
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
||||
"$defs": {
|
||||
"integer": {
|
||||
"type": "integer"
|
||||
},
|
||||
"refToInteger": {
|
||||
"$ref": "#/$defs/integer"
|
||||
}
|
||||
}
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue