The jsonschema package is part of of the API of the mcp package, so it should not be internal. Change-Id: I9520797837329fc2cda09c2f46ec4d48d031b9d3 Reviewed-on: https://go-review.googlesource.com/c/tools/+/669996 LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Robert Findley <rfindley@google.com>
1601 lines
47 KiB
JSON
1601 lines
47 KiB
JSON
[
|
|
{
|
|
"description": "unevaluatedProperties true",
|
|
"schema": {
|
|
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
|
"type": "object",
|
|
"unevaluatedProperties": true
|
|
},
|
|
"tests": [
|
|
{
|
|
"description": "with no unevaluated properties",
|
|
"data": {},
|
|
"valid": true
|
|
},
|
|
{
|
|
"description": "with unevaluated properties",
|
|
"data": {
|
|
"foo": "foo"
|
|
},
|
|
"valid": true
|
|
}
|
|
]
|
|
},
|
|
{
|
|
"description": "unevaluatedProperties schema",
|
|
"schema": {
|
|
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
|
"type": "object",
|
|
"unevaluatedProperties": {
|
|
"type": "string",
|
|
"minLength": 3
|
|
}
|
|
},
|
|
"tests": [
|
|
{
|
|
"description": "with no unevaluated properties",
|
|
"data": {},
|
|
"valid": true
|
|
},
|
|
{
|
|
"description": "with valid unevaluated properties",
|
|
"data": {
|
|
"foo": "foo"
|
|
},
|
|
"valid": true
|
|
},
|
|
{
|
|
"description": "with invalid unevaluated properties",
|
|
"data": {
|
|
"foo": "fo"
|
|
},
|
|
"valid": false
|
|
}
|
|
]
|
|
},
|
|
{
|
|
"description": "unevaluatedProperties false",
|
|
"schema": {
|
|
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
|
"type": "object",
|
|
"unevaluatedProperties": false
|
|
},
|
|
"tests": [
|
|
{
|
|
"description": "with no unevaluated properties",
|
|
"data": {},
|
|
"valid": true
|
|
},
|
|
{
|
|
"description": "with unevaluated properties",
|
|
"data": {
|
|
"foo": "foo"
|
|
},
|
|
"valid": false
|
|
}
|
|
]
|
|
},
|
|
{
|
|
"description": "unevaluatedProperties with adjacent properties",
|
|
"schema": {
|
|
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
|
"type": "object",
|
|
"properties": {
|
|
"foo": { "type": "string" }
|
|
},
|
|
"unevaluatedProperties": false
|
|
},
|
|
"tests": [
|
|
{
|
|
"description": "with no unevaluated properties",
|
|
"data": {
|
|
"foo": "foo"
|
|
},
|
|
"valid": true
|
|
},
|
|
{
|
|
"description": "with unevaluated properties",
|
|
"data": {
|
|
"foo": "foo",
|
|
"bar": "bar"
|
|
},
|
|
"valid": false
|
|
}
|
|
]
|
|
},
|
|
{
|
|
"description": "unevaluatedProperties with adjacent patternProperties",
|
|
"schema": {
|
|
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
|
"type": "object",
|
|
"patternProperties": {
|
|
"^foo": { "type": "string" }
|
|
},
|
|
"unevaluatedProperties": false
|
|
},
|
|
"tests": [
|
|
{
|
|
"description": "with no unevaluated properties",
|
|
"data": {
|
|
"foo": "foo"
|
|
},
|
|
"valid": true
|
|
},
|
|
{
|
|
"description": "with unevaluated properties",
|
|
"data": {
|
|
"foo": "foo",
|
|
"bar": "bar"
|
|
},
|
|
"valid": false
|
|
}
|
|
]
|
|
},
|
|
{
|
|
"description": "unevaluatedProperties with adjacent additionalProperties",
|
|
"schema": {
|
|
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
|
"type": "object",
|
|
"properties": {
|
|
"foo": { "type": "string" }
|
|
},
|
|
"additionalProperties": true,
|
|
"unevaluatedProperties": false
|
|
},
|
|
"tests": [
|
|
{
|
|
"description": "with no additional properties",
|
|
"data": {
|
|
"foo": "foo"
|
|
},
|
|
"valid": true
|
|
},
|
|
{
|
|
"description": "with additional properties",
|
|
"data": {
|
|
"foo": "foo",
|
|
"bar": "bar"
|
|
},
|
|
"valid": true
|
|
}
|
|
]
|
|
},
|
|
{
|
|
"description": "unevaluatedProperties with nested properties",
|
|
"schema": {
|
|
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
|
"type": "object",
|
|
"properties": {
|
|
"foo": { "type": "string" }
|
|
},
|
|
"allOf": [
|
|
{
|
|
"properties": {
|
|
"bar": { "type": "string" }
|
|
}
|
|
}
|
|
],
|
|
"unevaluatedProperties": false
|
|
},
|
|
"tests": [
|
|
{
|
|
"description": "with no additional properties",
|
|
"data": {
|
|
"foo": "foo",
|
|
"bar": "bar"
|
|
},
|
|
"valid": true
|
|
},
|
|
{
|
|
"description": "with additional properties",
|
|
"data": {
|
|
"foo": "foo",
|
|
"bar": "bar",
|
|
"baz": "baz"
|
|
},
|
|
"valid": false
|
|
}
|
|
]
|
|
},
|
|
{
|
|
"description": "unevaluatedProperties with nested patternProperties",
|
|
"schema": {
|
|
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
|
"type": "object",
|
|
"properties": {
|
|
"foo": { "type": "string" }
|
|
},
|
|
"allOf": [
|
|
{
|
|
"patternProperties": {
|
|
"^bar": { "type": "string" }
|
|
}
|
|
}
|
|
],
|
|
"unevaluatedProperties": false
|
|
},
|
|
"tests": [
|
|
{
|
|
"description": "with no additional properties",
|
|
"data": {
|
|
"foo": "foo",
|
|
"bar": "bar"
|
|
},
|
|
"valid": true
|
|
},
|
|
{
|
|
"description": "with additional properties",
|
|
"data": {
|
|
"foo": "foo",
|
|
"bar": "bar",
|
|
"baz": "baz"
|
|
},
|
|
"valid": false
|
|
}
|
|
]
|
|
},
|
|
{
|
|
"description": "unevaluatedProperties with nested additionalProperties",
|
|
"schema": {
|
|
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
|
"type": "object",
|
|
"properties": {
|
|
"foo": { "type": "string" }
|
|
},
|
|
"allOf": [
|
|
{
|
|
"additionalProperties": true
|
|
}
|
|
],
|
|
"unevaluatedProperties": false
|
|
},
|
|
"tests": [
|
|
{
|
|
"description": "with no additional properties",
|
|
"data": {
|
|
"foo": "foo"
|
|
},
|
|
"valid": true
|
|
},
|
|
{
|
|
"description": "with additional properties",
|
|
"data": {
|
|
"foo": "foo",
|
|
"bar": "bar"
|
|
},
|
|
"valid": true
|
|
}
|
|
]
|
|
},
|
|
{
|
|
"description": "unevaluatedProperties with nested unevaluatedProperties",
|
|
"schema": {
|
|
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
|
"type": "object",
|
|
"properties": {
|
|
"foo": { "type": "string" }
|
|
},
|
|
"allOf": [
|
|
{
|
|
"unevaluatedProperties": true
|
|
}
|
|
],
|
|
"unevaluatedProperties": {
|
|
"type": "string",
|
|
"maxLength": 2
|
|
}
|
|
},
|
|
"tests": [
|
|
{
|
|
"description": "with no nested unevaluated properties",
|
|
"data": {
|
|
"foo": "foo"
|
|
},
|
|
"valid": true
|
|
},
|
|
{
|
|
"description": "with nested unevaluated properties",
|
|
"data": {
|
|
"foo": "foo",
|
|
"bar": "bar"
|
|
},
|
|
"valid": true
|
|
}
|
|
]
|
|
},
|
|
{
|
|
"description": "unevaluatedProperties with anyOf",
|
|
"schema": {
|
|
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
|
"type": "object",
|
|
"properties": {
|
|
"foo": { "type": "string" }
|
|
},
|
|
"anyOf": [
|
|
{
|
|
"properties": {
|
|
"bar": { "const": "bar" }
|
|
},
|
|
"required": ["bar"]
|
|
},
|
|
{
|
|
"properties": {
|
|
"baz": { "const": "baz" }
|
|
},
|
|
"required": ["baz"]
|
|
},
|
|
{
|
|
"properties": {
|
|
"quux": { "const": "quux" }
|
|
},
|
|
"required": ["quux"]
|
|
}
|
|
],
|
|
"unevaluatedProperties": false
|
|
},
|
|
"tests": [
|
|
{
|
|
"description": "when one matches and has no unevaluated properties",
|
|
"data": {
|
|
"foo": "foo",
|
|
"bar": "bar"
|
|
},
|
|
"valid": true
|
|
},
|
|
{
|
|
"description": "when one matches and has unevaluated properties",
|
|
"data": {
|
|
"foo": "foo",
|
|
"bar": "bar",
|
|
"baz": "not-baz"
|
|
},
|
|
"valid": false
|
|
},
|
|
{
|
|
"description": "when two match and has no unevaluated properties",
|
|
"data": {
|
|
"foo": "foo",
|
|
"bar": "bar",
|
|
"baz": "baz"
|
|
},
|
|
"valid": true
|
|
},
|
|
{
|
|
"description": "when two match and has unevaluated properties",
|
|
"data": {
|
|
"foo": "foo",
|
|
"bar": "bar",
|
|
"baz": "baz",
|
|
"quux": "not-quux"
|
|
},
|
|
"valid": false
|
|
}
|
|
]
|
|
},
|
|
{
|
|
"description": "unevaluatedProperties with oneOf",
|
|
"schema": {
|
|
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
|
"type": "object",
|
|
"properties": {
|
|
"foo": { "type": "string" }
|
|
},
|
|
"oneOf": [
|
|
{
|
|
"properties": {
|
|
"bar": { "const": "bar" }
|
|
},
|
|
"required": ["bar"]
|
|
},
|
|
{
|
|
"properties": {
|
|
"baz": { "const": "baz" }
|
|
},
|
|
"required": ["baz"]
|
|
}
|
|
],
|
|
"unevaluatedProperties": false
|
|
},
|
|
"tests": [
|
|
{
|
|
"description": "with no unevaluated properties",
|
|
"data": {
|
|
"foo": "foo",
|
|
"bar": "bar"
|
|
},
|
|
"valid": true
|
|
},
|
|
{
|
|
"description": "with unevaluated properties",
|
|
"data": {
|
|
"foo": "foo",
|
|
"bar": "bar",
|
|
"quux": "quux"
|
|
},
|
|
"valid": false
|
|
}
|
|
]
|
|
},
|
|
{
|
|
"description": "unevaluatedProperties with not",
|
|
"schema": {
|
|
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
|
"type": "object",
|
|
"properties": {
|
|
"foo": { "type": "string" }
|
|
},
|
|
"not": {
|
|
"not": {
|
|
"properties": {
|
|
"bar": { "const": "bar" }
|
|
},
|
|
"required": ["bar"]
|
|
}
|
|
},
|
|
"unevaluatedProperties": false
|
|
},
|
|
"tests": [
|
|
{
|
|
"description": "with unevaluated properties",
|
|
"data": {
|
|
"foo": "foo",
|
|
"bar": "bar"
|
|
},
|
|
"valid": false
|
|
}
|
|
]
|
|
},
|
|
{
|
|
"description": "unevaluatedProperties with if/then/else",
|
|
"schema": {
|
|
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
|
"type": "object",
|
|
"if": {
|
|
"properties": {
|
|
"foo": { "const": "then" }
|
|
},
|
|
"required": ["foo"]
|
|
},
|
|
"then": {
|
|
"properties": {
|
|
"bar": { "type": "string" }
|
|
},
|
|
"required": ["bar"]
|
|
},
|
|
"else": {
|
|
"properties": {
|
|
"baz": { "type": "string" }
|
|
},
|
|
"required": ["baz"]
|
|
},
|
|
"unevaluatedProperties": false
|
|
},
|
|
"tests": [
|
|
{
|
|
"description": "when if is true and has no unevaluated properties",
|
|
"data": {
|
|
"foo": "then",
|
|
"bar": "bar"
|
|
},
|
|
"valid": true
|
|
},
|
|
{
|
|
"description": "when if is true and has unevaluated properties",
|
|
"data": {
|
|
"foo": "then",
|
|
"bar": "bar",
|
|
"baz": "baz"
|
|
},
|
|
"valid": false
|
|
},
|
|
{
|
|
"description": "when if is false and has no unevaluated properties",
|
|
"data": {
|
|
"baz": "baz"
|
|
},
|
|
"valid": true
|
|
},
|
|
{
|
|
"description": "when if is false and has unevaluated properties",
|
|
"data": {
|
|
"foo": "else",
|
|
"baz": "baz"
|
|
},
|
|
"valid": false
|
|
}
|
|
]
|
|
},
|
|
{
|
|
"description": "unevaluatedProperties with if/then/else, then not defined",
|
|
"schema": {
|
|
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
|
"type": "object",
|
|
"if": {
|
|
"properties": {
|
|
"foo": { "const": "then" }
|
|
},
|
|
"required": ["foo"]
|
|
},
|
|
"else": {
|
|
"properties": {
|
|
"baz": { "type": "string" }
|
|
},
|
|
"required": ["baz"]
|
|
},
|
|
"unevaluatedProperties": false
|
|
},
|
|
"tests": [
|
|
{
|
|
"description": "when if is true and has no unevaluated properties",
|
|
"data": {
|
|
"foo": "then",
|
|
"bar": "bar"
|
|
},
|
|
"valid": false
|
|
},
|
|
{
|
|
"description": "when if is true and has unevaluated properties",
|
|
"data": {
|
|
"foo": "then",
|
|
"bar": "bar",
|
|
"baz": "baz"
|
|
},
|
|
"valid": false
|
|
},
|
|
{
|
|
"description": "when if is false and has no unevaluated properties",
|
|
"data": {
|
|
"baz": "baz"
|
|
},
|
|
"valid": true
|
|
},
|
|
{
|
|
"description": "when if is false and has unevaluated properties",
|
|
"data": {
|
|
"foo": "else",
|
|
"baz": "baz"
|
|
},
|
|
"valid": false
|
|
}
|
|
]
|
|
},
|
|
{
|
|
"description": "unevaluatedProperties with if/then/else, else not defined",
|
|
"schema": {
|
|
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
|
"type": "object",
|
|
"if": {
|
|
"properties": {
|
|
"foo": { "const": "then" }
|
|
},
|
|
"required": ["foo"]
|
|
},
|
|
"then": {
|
|
"properties": {
|
|
"bar": { "type": "string" }
|
|
},
|
|
"required": ["bar"]
|
|
},
|
|
"unevaluatedProperties": false
|
|
},
|
|
"tests": [
|
|
{
|
|
"description": "when if is true and has no unevaluated properties",
|
|
"data": {
|
|
"foo": "then",
|
|
"bar": "bar"
|
|
},
|
|
"valid": true
|
|
},
|
|
{
|
|
"description": "when if is true and has unevaluated properties",
|
|
"data": {
|
|
"foo": "then",
|
|
"bar": "bar",
|
|
"baz": "baz"
|
|
},
|
|
"valid": false
|
|
},
|
|
{
|
|
"description": "when if is false and has no unevaluated properties",
|
|
"data": {
|
|
"baz": "baz"
|
|
},
|
|
"valid": false
|
|
},
|
|
{
|
|
"description": "when if is false and has unevaluated properties",
|
|
"data": {
|
|
"foo": "else",
|
|
"baz": "baz"
|
|
},
|
|
"valid": false
|
|
}
|
|
]
|
|
},
|
|
{
|
|
"description": "unevaluatedProperties with dependentSchemas",
|
|
"schema": {
|
|
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
|
"type": "object",
|
|
"properties": {
|
|
"foo": { "type": "string" }
|
|
},
|
|
"dependentSchemas": {
|
|
"foo": {
|
|
"properties": {
|
|
"bar": { "const": "bar" }
|
|
},
|
|
"required": ["bar"]
|
|
}
|
|
},
|
|
"unevaluatedProperties": false
|
|
},
|
|
"tests": [
|
|
{
|
|
"description": "with no unevaluated properties",
|
|
"data": {
|
|
"foo": "foo",
|
|
"bar": "bar"
|
|
},
|
|
"valid": true
|
|
},
|
|
{
|
|
"description": "with unevaluated properties",
|
|
"data": {
|
|
"bar": "bar"
|
|
},
|
|
"valid": false
|
|
}
|
|
]
|
|
},
|
|
{
|
|
"description": "unevaluatedProperties with boolean schemas",
|
|
"schema": {
|
|
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
|
"type": "object",
|
|
"properties": {
|
|
"foo": { "type": "string" }
|
|
},
|
|
"allOf": [true],
|
|
"unevaluatedProperties": false
|
|
},
|
|
"tests": [
|
|
{
|
|
"description": "with no unevaluated properties",
|
|
"data": {
|
|
"foo": "foo"
|
|
},
|
|
"valid": true
|
|
},
|
|
{
|
|
"description": "with unevaluated properties",
|
|
"data": {
|
|
"bar": "bar"
|
|
},
|
|
"valid": false
|
|
}
|
|
]
|
|
},
|
|
{
|
|
"description": "unevaluatedProperties with $ref",
|
|
"schema": {
|
|
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
|
"type": "object",
|
|
"$ref": "#/$defs/bar",
|
|
"properties": {
|
|
"foo": { "type": "string" }
|
|
},
|
|
"unevaluatedProperties": false,
|
|
"$defs": {
|
|
"bar": {
|
|
"properties": {
|
|
"bar": { "type": "string" }
|
|
}
|
|
}
|
|
}
|
|
},
|
|
"tests": [
|
|
{
|
|
"description": "with no unevaluated properties",
|
|
"data": {
|
|
"foo": "foo",
|
|
"bar": "bar"
|
|
},
|
|
"valid": true
|
|
},
|
|
{
|
|
"description": "with unevaluated properties",
|
|
"data": {
|
|
"foo": "foo",
|
|
"bar": "bar",
|
|
"baz": "baz"
|
|
},
|
|
"valid": false
|
|
}
|
|
]
|
|
},
|
|
{
|
|
"description": "unevaluatedProperties before $ref",
|
|
"schema": {
|
|
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
|
"type": "object",
|
|
"unevaluatedProperties": false,
|
|
"properties": {
|
|
"foo": { "type": "string" }
|
|
},
|
|
"$ref": "#/$defs/bar",
|
|
"$defs": {
|
|
"bar": {
|
|
"properties": {
|
|
"bar": { "type": "string" }
|
|
}
|
|
}
|
|
}
|
|
},
|
|
"tests": [
|
|
{
|
|
"description": "with no unevaluated properties",
|
|
"data": {
|
|
"foo": "foo",
|
|
"bar": "bar"
|
|
},
|
|
"valid": true
|
|
},
|
|
{
|
|
"description": "with unevaluated properties",
|
|
"data": {
|
|
"foo": "foo",
|
|
"bar": "bar",
|
|
"baz": "baz"
|
|
},
|
|
"valid": false
|
|
}
|
|
]
|
|
},
|
|
{
|
|
"description": "unevaluatedProperties with $dynamicRef",
|
|
"schema": {
|
|
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
|
"$id": "https://example.com/unevaluated-properties-with-dynamic-ref/derived",
|
|
|
|
"$ref": "./baseSchema",
|
|
|
|
"$defs": {
|
|
"derived": {
|
|
"$dynamicAnchor": "addons",
|
|
"properties": {
|
|
"bar": { "type": "string" }
|
|
}
|
|
},
|
|
"baseSchema": {
|
|
"$id": "./baseSchema",
|
|
|
|
"$comment": "unevaluatedProperties comes first so it's more likely to catch bugs with implementations that are sensitive to keyword ordering",
|
|
"unevaluatedProperties": false,
|
|
"type": "object",
|
|
"properties": {
|
|
"foo": { "type": "string" }
|
|
},
|
|
"$dynamicRef": "#addons",
|
|
|
|
"$defs": {
|
|
"defaultAddons": {
|
|
"$comment": "Needed to satisfy the bookending requirement",
|
|
"$dynamicAnchor": "addons"
|
|
}
|
|
}
|
|
}
|
|
}
|
|
},
|
|
"tests": [
|
|
{
|
|
"description": "with no unevaluated properties",
|
|
"data": {
|
|
"foo": "foo",
|
|
"bar": "bar"
|
|
},
|
|
"valid": true
|
|
},
|
|
{
|
|
"description": "with unevaluated properties",
|
|
"data": {
|
|
"foo": "foo",
|
|
"bar": "bar",
|
|
"baz": "baz"
|
|
},
|
|
"valid": false
|
|
}
|
|
]
|
|
},
|
|
{
|
|
"description": "unevaluatedProperties can't see inside cousins",
|
|
"schema": {
|
|
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
|
"allOf": [
|
|
{
|
|
"properties": {
|
|
"foo": true
|
|
}
|
|
},
|
|
{
|
|
"unevaluatedProperties": false
|
|
}
|
|
]
|
|
},
|
|
"tests": [
|
|
{
|
|
"description": "always fails",
|
|
"data": {
|
|
"foo": 1
|
|
},
|
|
"valid": false
|
|
}
|
|
]
|
|
},
|
|
{
|
|
"description": "unevaluatedProperties can't see inside cousins (reverse order)",
|
|
"schema": {
|
|
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
|
"allOf": [
|
|
{
|
|
"unevaluatedProperties": false
|
|
},
|
|
{
|
|
"properties": {
|
|
"foo": true
|
|
}
|
|
}
|
|
]
|
|
},
|
|
"tests": [
|
|
{
|
|
"description": "always fails",
|
|
"data": {
|
|
"foo": 1
|
|
},
|
|
"valid": false
|
|
}
|
|
]
|
|
},
|
|
{
|
|
"description": "nested unevaluatedProperties, outer false, inner true, properties outside",
|
|
"schema": {
|
|
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
|
"type": "object",
|
|
"properties": {
|
|
"foo": { "type": "string" }
|
|
},
|
|
"allOf": [
|
|
{
|
|
"unevaluatedProperties": true
|
|
}
|
|
],
|
|
"unevaluatedProperties": false
|
|
},
|
|
"tests": [
|
|
{
|
|
"description": "with no nested unevaluated properties",
|
|
"data": {
|
|
"foo": "foo"
|
|
},
|
|
"valid": true
|
|
},
|
|
{
|
|
"description": "with nested unevaluated properties",
|
|
"data": {
|
|
"foo": "foo",
|
|
"bar": "bar"
|
|
},
|
|
"valid": true
|
|
}
|
|
]
|
|
},
|
|
{
|
|
"description": "nested unevaluatedProperties, outer false, inner true, properties inside",
|
|
"schema": {
|
|
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
|
"type": "object",
|
|
"allOf": [
|
|
{
|
|
"properties": {
|
|
"foo": { "type": "string" }
|
|
},
|
|
"unevaluatedProperties": true
|
|
}
|
|
],
|
|
"unevaluatedProperties": false
|
|
},
|
|
"tests": [
|
|
{
|
|
"description": "with no nested unevaluated properties",
|
|
"data": {
|
|
"foo": "foo"
|
|
},
|
|
"valid": true
|
|
},
|
|
{
|
|
"description": "with nested unevaluated properties",
|
|
"data": {
|
|
"foo": "foo",
|
|
"bar": "bar"
|
|
},
|
|
"valid": true
|
|
}
|
|
]
|
|
},
|
|
{
|
|
"description": "nested unevaluatedProperties, outer true, inner false, properties outside",
|
|
"schema": {
|
|
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
|
"type": "object",
|
|
"properties": {
|
|
"foo": { "type": "string" }
|
|
},
|
|
"allOf": [
|
|
{
|
|
"unevaluatedProperties": false
|
|
}
|
|
],
|
|
"unevaluatedProperties": true
|
|
},
|
|
"tests": [
|
|
{
|
|
"description": "with no nested unevaluated properties",
|
|
"data": {
|
|
"foo": "foo"
|
|
},
|
|
"valid": false
|
|
},
|
|
{
|
|
"description": "with nested unevaluated properties",
|
|
"data": {
|
|
"foo": "foo",
|
|
"bar": "bar"
|
|
},
|
|
"valid": false
|
|
}
|
|
]
|
|
},
|
|
{
|
|
"description": "nested unevaluatedProperties, outer true, inner false, properties inside",
|
|
"schema": {
|
|
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
|
"type": "object",
|
|
"allOf": [
|
|
{
|
|
"properties": {
|
|
"foo": { "type": "string" }
|
|
},
|
|
"unevaluatedProperties": false
|
|
}
|
|
],
|
|
"unevaluatedProperties": true
|
|
},
|
|
"tests": [
|
|
{
|
|
"description": "with no nested unevaluated properties",
|
|
"data": {
|
|
"foo": "foo"
|
|
},
|
|
"valid": true
|
|
},
|
|
{
|
|
"description": "with nested unevaluated properties",
|
|
"data": {
|
|
"foo": "foo",
|
|
"bar": "bar"
|
|
},
|
|
"valid": false
|
|
}
|
|
]
|
|
},
|
|
{
|
|
"description": "cousin unevaluatedProperties, true and false, true with properties",
|
|
"schema": {
|
|
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
|
"type": "object",
|
|
"allOf": [
|
|
{
|
|
"properties": {
|
|
"foo": { "type": "string" }
|
|
},
|
|
"unevaluatedProperties": true
|
|
},
|
|
{
|
|
"unevaluatedProperties": false
|
|
}
|
|
]
|
|
},
|
|
"tests": [
|
|
{
|
|
"description": "with no nested unevaluated properties",
|
|
"data": {
|
|
"foo": "foo"
|
|
},
|
|
"valid": false
|
|
},
|
|
{
|
|
"description": "with nested unevaluated properties",
|
|
"data": {
|
|
"foo": "foo",
|
|
"bar": "bar"
|
|
},
|
|
"valid": false
|
|
}
|
|
]
|
|
},
|
|
{
|
|
"description": "cousin unevaluatedProperties, true and false, false with properties",
|
|
"schema": {
|
|
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
|
"type": "object",
|
|
"allOf": [
|
|
{
|
|
"unevaluatedProperties": true
|
|
},
|
|
{
|
|
"properties": {
|
|
"foo": { "type": "string" }
|
|
},
|
|
"unevaluatedProperties": false
|
|
}
|
|
]
|
|
},
|
|
"tests": [
|
|
{
|
|
"description": "with no nested unevaluated properties",
|
|
"data": {
|
|
"foo": "foo"
|
|
},
|
|
"valid": true
|
|
},
|
|
{
|
|
"description": "with nested unevaluated properties",
|
|
"data": {
|
|
"foo": "foo",
|
|
"bar": "bar"
|
|
},
|
|
"valid": false
|
|
}
|
|
]
|
|
},
|
|
{
|
|
"description": "property is evaluated in an uncle schema to unevaluatedProperties",
|
|
"comment": "see https://stackoverflow.com/questions/66936884/deeply-nested-unevaluatedproperties-and-their-expectations",
|
|
"schema": {
|
|
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
|
"type": "object",
|
|
"properties": {
|
|
"foo": {
|
|
"type": "object",
|
|
"properties": {
|
|
"bar": {
|
|
"type": "string"
|
|
}
|
|
},
|
|
"unevaluatedProperties": false
|
|
}
|
|
},
|
|
"anyOf": [
|
|
{
|
|
"properties": {
|
|
"foo": {
|
|
"properties": {
|
|
"faz": {
|
|
"type": "string"
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
]
|
|
},
|
|
"tests": [
|
|
{
|
|
"description": "no extra properties",
|
|
"data": {
|
|
"foo": {
|
|
"bar": "test"
|
|
}
|
|
},
|
|
"valid": true
|
|
},
|
|
{
|
|
"description": "uncle keyword evaluation is not significant",
|
|
"data": {
|
|
"foo": {
|
|
"bar": "test",
|
|
"faz": "test"
|
|
}
|
|
},
|
|
"valid": false
|
|
}
|
|
]
|
|
},
|
|
{
|
|
"description": "in-place applicator siblings, allOf has unevaluated",
|
|
"schema": {
|
|
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
|
"type": "object",
|
|
"allOf": [
|
|
{
|
|
"properties": {
|
|
"foo": true
|
|
},
|
|
"unevaluatedProperties": false
|
|
}
|
|
],
|
|
"anyOf": [
|
|
{
|
|
"properties": {
|
|
"bar": true
|
|
}
|
|
}
|
|
]
|
|
},
|
|
"tests": [
|
|
{
|
|
"description": "base case: both properties present",
|
|
"data": {
|
|
"foo": 1,
|
|
"bar": 1
|
|
},
|
|
"valid": false
|
|
},
|
|
{
|
|
"description": "in place applicator siblings, bar is missing",
|
|
"data": {
|
|
"foo": 1
|
|
},
|
|
"valid": true
|
|
},
|
|
{
|
|
"description": "in place applicator siblings, foo is missing",
|
|
"data": {
|
|
"bar": 1
|
|
},
|
|
"valid": false
|
|
}
|
|
]
|
|
},
|
|
{
|
|
"description": "in-place applicator siblings, anyOf has unevaluated",
|
|
"schema": {
|
|
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
|
"type": "object",
|
|
"allOf": [
|
|
{
|
|
"properties": {
|
|
"foo": true
|
|
}
|
|
}
|
|
],
|
|
"anyOf": [
|
|
{
|
|
"properties": {
|
|
"bar": true
|
|
},
|
|
"unevaluatedProperties": false
|
|
}
|
|
]
|
|
},
|
|
"tests": [
|
|
{
|
|
"description": "base case: both properties present",
|
|
"data": {
|
|
"foo": 1,
|
|
"bar": 1
|
|
},
|
|
"valid": false
|
|
},
|
|
{
|
|
"description": "in place applicator siblings, bar is missing",
|
|
"data": {
|
|
"foo": 1
|
|
},
|
|
"valid": false
|
|
},
|
|
{
|
|
"description": "in place applicator siblings, foo is missing",
|
|
"data": {
|
|
"bar": 1
|
|
},
|
|
"valid": true
|
|
}
|
|
]
|
|
},
|
|
{
|
|
"description": "unevaluatedProperties + single cyclic ref",
|
|
"schema": {
|
|
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
|
"type": "object",
|
|
"properties": {
|
|
"x": { "$ref": "#" }
|
|
},
|
|
"unevaluatedProperties": false
|
|
},
|
|
"tests": [
|
|
{
|
|
"description": "Empty is valid",
|
|
"data": {},
|
|
"valid": true
|
|
},
|
|
{
|
|
"description": "Single is valid",
|
|
"data": { "x": {} },
|
|
"valid": true
|
|
},
|
|
{
|
|
"description": "Unevaluated on 1st level is invalid",
|
|
"data": { "x": {}, "y": {} },
|
|
"valid": false
|
|
},
|
|
{
|
|
"description": "Nested is valid",
|
|
"data": { "x": { "x": {} } },
|
|
"valid": true
|
|
},
|
|
{
|
|
"description": "Unevaluated on 2nd level is invalid",
|
|
"data": { "x": { "x": {}, "y": {} } },
|
|
"valid": false
|
|
},
|
|
{
|
|
"description": "Deep nested is valid",
|
|
"data": { "x": { "x": { "x": {} } } },
|
|
"valid": true
|
|
},
|
|
{
|
|
"description": "Unevaluated on 3rd level is invalid",
|
|
"data": { "x": { "x": { "x": {}, "y": {} } } },
|
|
"valid": false
|
|
}
|
|
]
|
|
},
|
|
{
|
|
"description": "unevaluatedProperties + ref inside allOf / oneOf",
|
|
"schema": {
|
|
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
|
"$defs": {
|
|
"one": {
|
|
"properties": { "a": true }
|
|
},
|
|
"two": {
|
|
"required": ["x"],
|
|
"properties": { "x": true }
|
|
}
|
|
},
|
|
"allOf": [
|
|
{ "$ref": "#/$defs/one" },
|
|
{ "properties": { "b": true } },
|
|
{
|
|
"oneOf": [
|
|
{ "$ref": "#/$defs/two" },
|
|
{
|
|
"required": ["y"],
|
|
"properties": { "y": true }
|
|
}
|
|
]
|
|
}
|
|
],
|
|
"unevaluatedProperties": false
|
|
},
|
|
"tests": [
|
|
{
|
|
"description": "Empty is invalid (no x or y)",
|
|
"data": {},
|
|
"valid": false
|
|
},
|
|
{
|
|
"description": "a and b are invalid (no x or y)",
|
|
"data": { "a": 1, "b": 1 },
|
|
"valid": false
|
|
},
|
|
{
|
|
"description": "x and y are invalid",
|
|
"data": { "x": 1, "y": 1 },
|
|
"valid": false
|
|
},
|
|
{
|
|
"description": "a and x are valid",
|
|
"data": { "a": 1, "x": 1 },
|
|
"valid": true
|
|
},
|
|
{
|
|
"description": "a and y are valid",
|
|
"data": { "a": 1, "y": 1 },
|
|
"valid": true
|
|
},
|
|
{
|
|
"description": "a and b and x are valid",
|
|
"data": { "a": 1, "b": 1, "x": 1 },
|
|
"valid": true
|
|
},
|
|
{
|
|
"description": "a and b and y are valid",
|
|
"data": { "a": 1, "b": 1, "y": 1 },
|
|
"valid": true
|
|
},
|
|
{
|
|
"description": "a and b and x and y are invalid",
|
|
"data": { "a": 1, "b": 1, "x": 1, "y": 1 },
|
|
"valid": false
|
|
}
|
|
]
|
|
},
|
|
{
|
|
"description": "dynamic evalation inside nested refs",
|
|
"schema": {
|
|
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
|
"$defs": {
|
|
"one": {
|
|
"oneOf": [
|
|
{ "$ref": "#/$defs/two" },
|
|
{ "required": ["b"], "properties": { "b": true } },
|
|
{ "required": ["xx"], "patternProperties": { "x": true } },
|
|
{ "required": ["all"], "unevaluatedProperties": true }
|
|
]
|
|
},
|
|
"two": {
|
|
"oneOf": [
|
|
{ "required": ["c"], "properties": { "c": true } },
|
|
{ "required": ["d"], "properties": { "d": true } }
|
|
]
|
|
}
|
|
},
|
|
"oneOf": [
|
|
{ "$ref": "#/$defs/one" },
|
|
{ "required": ["a"], "properties": { "a": true } }
|
|
],
|
|
"unevaluatedProperties": false
|
|
},
|
|
"tests": [
|
|
{
|
|
"description": "Empty is invalid",
|
|
"data": {},
|
|
"valid": false
|
|
},
|
|
{
|
|
"description": "a is valid",
|
|
"data": { "a": 1 },
|
|
"valid": true
|
|
},
|
|
{
|
|
"description": "b is valid",
|
|
"data": { "b": 1 },
|
|
"valid": true
|
|
},
|
|
{
|
|
"description": "c is valid",
|
|
"data": { "c": 1 },
|
|
"valid": true
|
|
},
|
|
{
|
|
"description": "d is valid",
|
|
"data": { "d": 1 },
|
|
"valid": true
|
|
},
|
|
{
|
|
"description": "a + b is invalid",
|
|
"data": { "a": 1, "b": 1 },
|
|
"valid": false
|
|
},
|
|
{
|
|
"description": "a + c is invalid",
|
|
"data": { "a": 1, "c": 1 },
|
|
"valid": false
|
|
},
|
|
{
|
|
"description": "a + d is invalid",
|
|
"data": { "a": 1, "d": 1 },
|
|
"valid": false
|
|
},
|
|
{
|
|
"description": "b + c is invalid",
|
|
"data": { "b": 1, "c": 1 },
|
|
"valid": false
|
|
},
|
|
{
|
|
"description": "b + d is invalid",
|
|
"data": { "b": 1, "d": 1 },
|
|
"valid": false
|
|
},
|
|
{
|
|
"description": "c + d is invalid",
|
|
"data": { "c": 1, "d": 1 },
|
|
"valid": false
|
|
},
|
|
{
|
|
"description": "xx is valid",
|
|
"data": { "xx": 1 },
|
|
"valid": true
|
|
},
|
|
{
|
|
"description": "xx + foox is valid",
|
|
"data": { "xx": 1, "foox": 1 },
|
|
"valid": true
|
|
},
|
|
{
|
|
"description": "xx + foo is invalid",
|
|
"data": { "xx": 1, "foo": 1 },
|
|
"valid": false
|
|
},
|
|
{
|
|
"description": "xx + a is invalid",
|
|
"data": { "xx": 1, "a": 1 },
|
|
"valid": false
|
|
},
|
|
{
|
|
"description": "xx + b is invalid",
|
|
"data": { "xx": 1, "b": 1 },
|
|
"valid": false
|
|
},
|
|
{
|
|
"description": "xx + c is invalid",
|
|
"data": { "xx": 1, "c": 1 },
|
|
"valid": false
|
|
},
|
|
{
|
|
"description": "xx + d is invalid",
|
|
"data": { "xx": 1, "d": 1 },
|
|
"valid": false
|
|
},
|
|
{
|
|
"description": "all is valid",
|
|
"data": { "all": 1 },
|
|
"valid": true
|
|
},
|
|
{
|
|
"description": "all + foo is valid",
|
|
"data": { "all": 1, "foo": 1 },
|
|
"valid": true
|
|
},
|
|
{
|
|
"description": "all + a is invalid",
|
|
"data": { "all": 1, "a": 1 },
|
|
"valid": false
|
|
}
|
|
]
|
|
},
|
|
{
|
|
"description": "non-object instances are valid",
|
|
"schema": {
|
|
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
|
"unevaluatedProperties": false
|
|
},
|
|
"tests": [
|
|
{
|
|
"description": "ignores booleans",
|
|
"data": true,
|
|
"valid": true
|
|
},
|
|
{
|
|
"description": "ignores integers",
|
|
"data": 123,
|
|
"valid": true
|
|
},
|
|
{
|
|
"description": "ignores floats",
|
|
"data": 1.0,
|
|
"valid": true
|
|
},
|
|
{
|
|
"description": "ignores arrays",
|
|
"data": [],
|
|
"valid": true
|
|
},
|
|
{
|
|
"description": "ignores strings",
|
|
"data": "foo",
|
|
"valid": true
|
|
},
|
|
{
|
|
"description": "ignores null",
|
|
"data": null,
|
|
"valid": true
|
|
}
|
|
]
|
|
},
|
|
{
|
|
"description": "unevaluatedProperties with null valued instance properties",
|
|
"schema": {
|
|
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
|
"unevaluatedProperties": {
|
|
"type": "null"
|
|
}
|
|
},
|
|
"tests": [
|
|
{
|
|
"description": "allows null valued properties",
|
|
"data": {"foo": null},
|
|
"valid": true
|
|
}
|
|
]
|
|
},
|
|
{
|
|
"description": "unevaluatedProperties not affected by propertyNames",
|
|
"schema": {
|
|
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
|
"propertyNames": {"maxLength": 1},
|
|
"unevaluatedProperties": {
|
|
"type": "number"
|
|
}
|
|
},
|
|
"tests": [
|
|
{
|
|
"description": "allows only number properties",
|
|
"data": {"a": 1},
|
|
"valid": true
|
|
},
|
|
{
|
|
"description": "string property is invalid",
|
|
"data": {"a": "b"},
|
|
"valid": false
|
|
}
|
|
]
|
|
},
|
|
{
|
|
"description": "unevaluatedProperties can see annotations from if without then and else",
|
|
"schema": {
|
|
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
|
"if": {
|
|
"patternProperties": {
|
|
"foo": {
|
|
"type": "string"
|
|
}
|
|
}
|
|
},
|
|
"unevaluatedProperties": false
|
|
},
|
|
"tests": [
|
|
{
|
|
"description": "valid in case if is evaluated",
|
|
"data": {
|
|
"foo": "a"
|
|
},
|
|
"valid": true
|
|
},
|
|
{
|
|
"description": "invalid in case if is evaluated",
|
|
"data": {
|
|
"bar": "a"
|
|
},
|
|
"valid": false
|
|
}
|
|
]
|
|
},
|
|
{
|
|
"description": "dependentSchemas with unevaluatedProperties",
|
|
"schema": {
|
|
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
|
"properties": {"foo2": {}},
|
|
"dependentSchemas": {
|
|
"foo" : {},
|
|
"foo2": {
|
|
"properties": {
|
|
"bar":{}
|
|
}
|
|
}
|
|
},
|
|
"unevaluatedProperties": false
|
|
},
|
|
"tests": [
|
|
{
|
|
"description": "unevaluatedProperties doesn't consider dependentSchemas",
|
|
"data": {"foo": ""},
|
|
"valid": false
|
|
},
|
|
{
|
|
"description": "unevaluatedProperties doesn't see bar when foo2 is absent",
|
|
"data": {"bar": ""},
|
|
"valid": false
|
|
},
|
|
{
|
|
"description": "unevaluatedProperties sees bar when foo2 is present",
|
|
"data": { "foo2": "", "bar": ""},
|
|
"valid": true
|
|
}
|
|
]
|
|
}
|
|
]
|