* Remove travis file * Apply pre-commit fixes * Modernize cmake file - Added JSON_VALIDATOR_SHARED_LIBS to properly handle shared-library - Bumped minimum cmake to 3.11 to use no-source add_library - Bumped minimum cmake to 3.14 to properly support FetchContent (FetchContent_MakeAvailable) - Converted Hunter package manager to FetchContent (It is plenty mature these days) - Added namespace to exported target - Made the cmake file compatible with FetchContent * Use simplified FetchContent CI * Add simple status messages * Handle nlohmann dependency Not an ideal approach, but required in order for the exported target to have appropriate linkage. Maybe this can be designed to become a PRIVATE link library, but then how does it ensure the target is installed? * Remove CMake-install test This will be moved to packaging integration tests * Enable code coverage * Reconfigure ci presets Signed-off-by: Cristian Le <cristian.le@mpsd.mpg.de>
613 lines
18 KiB
JSON
613 lines
18 KiB
JSON
[
|
|
{
|
|
"description": "root pointer ref",
|
|
"schema": {
|
|
"properties": {
|
|
"foo": {"$ref": "#"}
|
|
},
|
|
"additionalProperties": false
|
|
},
|
|
"tests": [
|
|
{
|
|
"description": "match",
|
|
"data": {"foo": false},
|
|
"valid": true
|
|
},
|
|
{
|
|
"description": "recursive match",
|
|
"data": {"foo": {"foo": false}},
|
|
"valid": true
|
|
},
|
|
{
|
|
"description": "mismatch",
|
|
"data": {"bar": false},
|
|
"valid": false
|
|
},
|
|
{
|
|
"description": "recursive mismatch",
|
|
"data": {"foo": {"bar": false}},
|
|
"valid": false
|
|
}
|
|
]
|
|
},
|
|
{
|
|
"description": "relative pointer ref to object",
|
|
"schema": {
|
|
"properties": {
|
|
"foo": {"type": "integer"},
|
|
"bar": {"$ref": "#/properties/foo"}
|
|
}
|
|
},
|
|
"tests": [
|
|
{
|
|
"description": "match",
|
|
"data": {"bar": 3},
|
|
"valid": true
|
|
},
|
|
{
|
|
"description": "mismatch",
|
|
"data": {"bar": true},
|
|
"valid": false
|
|
}
|
|
]
|
|
},
|
|
{
|
|
"description": "relative pointer ref to array",
|
|
"schema": {
|
|
"items": [
|
|
{"type": "integer"},
|
|
{"$ref": "#/items/0"}
|
|
]
|
|
},
|
|
"tests": [
|
|
{
|
|
"description": "match array",
|
|
"data": [1, 2],
|
|
"valid": true
|
|
},
|
|
{
|
|
"description": "mismatch array",
|
|
"data": [1, "foo"],
|
|
"valid": false
|
|
}
|
|
]
|
|
},
|
|
{
|
|
"description": "escaped pointer ref",
|
|
"schema": {
|
|
"definitions": {
|
|
"tilde~field": {"type": "integer"},
|
|
"slash/field": {"type": "integer"},
|
|
"percent%field": {"type": "integer"}
|
|
},
|
|
"properties": {
|
|
"tilde": {"$ref": "#/definitions/tilde~0field"},
|
|
"slash": {"$ref": "#/definitions/slash~1field"},
|
|
"percent": {"$ref": "#/definitions/percent%25field"}
|
|
}
|
|
},
|
|
"tests": [
|
|
{
|
|
"description": "slash invalid",
|
|
"data": {"slash": "aoeu"},
|
|
"valid": false
|
|
},
|
|
{
|
|
"description": "tilde invalid",
|
|
"data": {"tilde": "aoeu"},
|
|
"valid": false
|
|
},
|
|
{
|
|
"description": "percent invalid",
|
|
"data": {"percent": "aoeu"},
|
|
"valid": false
|
|
},
|
|
{
|
|
"description": "slash valid",
|
|
"data": {"slash": 123},
|
|
"valid": true
|
|
},
|
|
{
|
|
"description": "tilde valid",
|
|
"data": {"tilde": 123},
|
|
"valid": true
|
|
},
|
|
{
|
|
"description": "percent valid",
|
|
"data": {"percent": 123},
|
|
"valid": true
|
|
}
|
|
]
|
|
},
|
|
{
|
|
"description": "nested refs",
|
|
"schema": {
|
|
"definitions": {
|
|
"a": {"type": "integer"},
|
|
"b": {"$ref": "#/definitions/a"},
|
|
"c": {"$ref": "#/definitions/b"}
|
|
},
|
|
"allOf": [{ "$ref": "#/definitions/c" }]
|
|
},
|
|
"tests": [
|
|
{
|
|
"description": "nested ref valid",
|
|
"data": 5,
|
|
"valid": true
|
|
},
|
|
{
|
|
"description": "nested ref invalid",
|
|
"data": "a",
|
|
"valid": false
|
|
}
|
|
]
|
|
},
|
|
{
|
|
"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": "$ref prevents a sibling $id from changing the base uri",
|
|
"schema": {
|
|
"$id": "http://localhost:1234/sibling_id/base/",
|
|
"definitions": {
|
|
"foo": {
|
|
"$id": "http://localhost:1234/sibling_id/foo.json",
|
|
"minimum": 2
|
|
},
|
|
"base_foo": {
|
|
"$comment": "this canonical uri is http://localhost:1234/sibling_id/base/foo.json",
|
|
"$id": "foo.json",
|
|
"minimum": 5
|
|
}
|
|
},
|
|
"allOf": [
|
|
{
|
|
"$comment": "$ref resolves to http://localhost:1234/sibling_id/base/foo.json, not ttp://localhost:1234/sibling_id/foo.json",
|
|
"$id": "http://localhost:1234/sibling_id/",
|
|
"$ref": "foo.json"
|
|
}
|
|
]
|
|
},
|
|
"tests": [
|
|
{
|
|
"description": "$ref resolves to /definitions/foo, data validates",
|
|
"data": 10,
|
|
"valid": true
|
|
},
|
|
{
|
|
"description": "$ref resolves to /definitions/foo, data does not validate",
|
|
"data": 1,
|
|
"valid": false
|
|
}
|
|
]
|
|
},
|
|
{
|
|
"description": "remote ref, containing refs itself",
|
|
"schema": {"$ref": "http://json-schema.org/draft-07/schema#"},
|
|
"tests": [
|
|
{
|
|
"description": "remote ref valid",
|
|
"data": {"minLength": 1},
|
|
"valid": true
|
|
},
|
|
{
|
|
"description": "remote ref invalid",
|
|
"data": {"minLength": -1},
|
|
"valid": false
|
|
}
|
|
]
|
|
},
|
|
{
|
|
"description": "property named $ref that is not a reference",
|
|
"schema": {
|
|
"properties": {
|
|
"$ref": {"type": "string"}
|
|
}
|
|
},
|
|
"tests": [
|
|
{
|
|
"description": "property named $ref valid",
|
|
"data": {"$ref": "a"},
|
|
"valid": true
|
|
},
|
|
{
|
|
"description": "property named $ref invalid",
|
|
"data": {"$ref": 2},
|
|
"valid": false
|
|
}
|
|
]
|
|
},
|
|
{
|
|
"description": "property named $ref, containing an actual $ref",
|
|
"schema": {
|
|
"properties": {
|
|
"$ref": {"$ref": "#/definitions/is-string"}
|
|
},
|
|
"definitions": {
|
|
"is-string": {
|
|
"type": "string"
|
|
}
|
|
}
|
|
},
|
|
"tests": [
|
|
{
|
|
"description": "property named $ref valid",
|
|
"data": {"$ref": "a"},
|
|
"valid": true
|
|
},
|
|
{
|
|
"description": "property named $ref invalid",
|
|
"data": {"$ref": 2},
|
|
"valid": false
|
|
}
|
|
]
|
|
},
|
|
{
|
|
"description": "$ref to boolean schema true",
|
|
"schema": {
|
|
"allOf": [{ "$ref": "#/definitions/bool" }],
|
|
"definitions": {
|
|
"bool": true
|
|
}
|
|
},
|
|
"tests": [
|
|
{
|
|
"description": "any value is valid",
|
|
"data": "foo",
|
|
"valid": true
|
|
}
|
|
]
|
|
},
|
|
{
|
|
"description": "$ref to boolean schema false",
|
|
"schema": {
|
|
"allOf": [{ "$ref": "#/definitions/bool" }],
|
|
"definitions": {
|
|
"bool": false
|
|
}
|
|
},
|
|
"tests": [
|
|
{
|
|
"description": "any value is invalid",
|
|
"data": "foo",
|
|
"valid": false
|
|
}
|
|
]
|
|
},
|
|
{
|
|
"description": "Recursive references between schemas",
|
|
"schema": {
|
|
"$id": "http://localhost:1234/tree",
|
|
"description": "tree of nodes",
|
|
"type": "object",
|
|
"properties": {
|
|
"meta": {"type": "string"},
|
|
"nodes": {
|
|
"type": "array",
|
|
"items": {"$ref": "node"}
|
|
}
|
|
},
|
|
"required": ["meta", "nodes"],
|
|
"definitions": {
|
|
"node": {
|
|
"$id": "http://localhost:1234/node",
|
|
"description": "node",
|
|
"type": "object",
|
|
"properties": {
|
|
"value": {"type": "number"},
|
|
"subtree": {"$ref": "tree"}
|
|
},
|
|
"required": ["value"]
|
|
}
|
|
}
|
|
},
|
|
"tests": [
|
|
{
|
|
"description": "valid tree",
|
|
"data": {
|
|
"meta": "root",
|
|
"nodes": [
|
|
{
|
|
"value": 1,
|
|
"subtree": {
|
|
"meta": "child",
|
|
"nodes": [
|
|
{"value": 1.1},
|
|
{"value": 1.2}
|
|
]
|
|
}
|
|
},
|
|
{
|
|
"value": 2,
|
|
"subtree": {
|
|
"meta": "child",
|
|
"nodes": [
|
|
{"value": 2.1},
|
|
{"value": 2.2}
|
|
]
|
|
}
|
|
}
|
|
]
|
|
},
|
|
"valid": true
|
|
},
|
|
{
|
|
"description": "invalid tree",
|
|
"data": {
|
|
"meta": "root",
|
|
"nodes": [
|
|
{
|
|
"value": 1,
|
|
"subtree": {
|
|
"meta": "child",
|
|
"nodes": [
|
|
{"value": "string is invalid"},
|
|
{"value": 1.2}
|
|
]
|
|
}
|
|
},
|
|
{
|
|
"value": 2,
|
|
"subtree": {
|
|
"meta": "child",
|
|
"nodes": [
|
|
{"value": 2.1},
|
|
{"value": 2.2}
|
|
]
|
|
}
|
|
}
|
|
]
|
|
},
|
|
"valid": false
|
|
}
|
|
]
|
|
},
|
|
{
|
|
"description": "refs with quote",
|
|
"schema": {
|
|
"properties": {
|
|
"foo\"bar": {"$ref": "#/definitions/foo%22bar"}
|
|
},
|
|
"definitions": {
|
|
"foo\"bar": {"type": "number"}
|
|
}
|
|
},
|
|
"tests": [
|
|
{
|
|
"description": "object with numbers is valid",
|
|
"data": {
|
|
"foo\"bar": 1
|
|
},
|
|
"valid": true
|
|
},
|
|
{
|
|
"description": "object with strings is invalid",
|
|
"data": {
|
|
"foo\"bar": "1"
|
|
},
|
|
"valid": false
|
|
}
|
|
]
|
|
},
|
|
{
|
|
"description": "Location-independent identifier",
|
|
"schema": {
|
|
"allOf": [{
|
|
"$ref": "#foo"
|
|
}],
|
|
"definitions": {
|
|
"A": {
|
|
"$id": "#foo",
|
|
"type": "integer"
|
|
}
|
|
}
|
|
},
|
|
"tests": [
|
|
{
|
|
"data": 1,
|
|
"description": "match",
|
|
"valid": true
|
|
},
|
|
{
|
|
"data": "a",
|
|
"description": "mismatch",
|
|
"valid": false
|
|
}
|
|
]
|
|
},
|
|
{
|
|
"description": "Location-independent identifier with base URI change in subschema",
|
|
"schema": {
|
|
"$id": "http://localhost:1234/root",
|
|
"allOf": [{
|
|
"$ref": "http://localhost:1234/nested.json#foo"
|
|
}],
|
|
"definitions": {
|
|
"A": {
|
|
"$id": "nested.json",
|
|
"definitions": {
|
|
"B": {
|
|
"$id": "#foo",
|
|
"type": "integer"
|
|
}
|
|
}
|
|
}
|
|
}
|
|
},
|
|
"tests": [
|
|
{
|
|
"data": 1,
|
|
"description": "match",
|
|
"valid": true
|
|
},
|
|
{
|
|
"data": "a",
|
|
"description": "mismatch",
|
|
"valid": false
|
|
}
|
|
]
|
|
},
|
|
{
|
|
"description": "naive replacement of $ref with its destination is not correct",
|
|
"schema": {
|
|
"definitions": {
|
|
"a_string": { "type": "string" }
|
|
},
|
|
"enum": [
|
|
{ "$ref": "#/definitions/a_string" }
|
|
]
|
|
},
|
|
"tests": [
|
|
{
|
|
"description": "do not evaluate the $ref inside the enum, matching any string",
|
|
"data": "this is a string",
|
|
"valid": false
|
|
},
|
|
{
|
|
"description": "do not evaluate the $ref inside the enum, definition exact match",
|
|
"data": { "type": "string" },
|
|
"valid": false
|
|
},
|
|
{
|
|
"description": "match the enum exactly",
|
|
"data": { "$ref": "#/definitions/a_string" },
|
|
"valid": true
|
|
}
|
|
]
|
|
},
|
|
{
|
|
"description": "refs with relative uris and defs",
|
|
"schema": {
|
|
"$id": "http://example.com/schema-relative-uri-defs1.json",
|
|
"properties": {
|
|
"foo": {
|
|
"$id": "schema-relative-uri-defs2.json",
|
|
"definitions": {
|
|
"inner": {
|
|
"properties": {
|
|
"bar": { "type": "string" }
|
|
}
|
|
}
|
|
},
|
|
"allOf": [ { "$ref": "#/definitions/inner" } ]
|
|
}
|
|
},
|
|
"allOf": [ { "$ref": "schema-relative-uri-defs2.json" } ]
|
|
},
|
|
"tests": [
|
|
{
|
|
"description": "invalid on inner field",
|
|
"data": {
|
|
"foo": {
|
|
"bar": 1
|
|
},
|
|
"bar": "a"
|
|
},
|
|
"valid": false
|
|
},
|
|
{
|
|
"description": "invalid on outer field",
|
|
"data": {
|
|
"foo": {
|
|
"bar": "a"
|
|
},
|
|
"bar": 1
|
|
},
|
|
"valid": false
|
|
},
|
|
{
|
|
"description": "valid on both fields",
|
|
"data": {
|
|
"foo": {
|
|
"bar": "a"
|
|
},
|
|
"bar": "a"
|
|
},
|
|
"valid": true
|
|
}
|
|
]
|
|
},
|
|
{
|
|
"description": "relative refs with absolute uris and defs",
|
|
"schema": {
|
|
"$id": "http://example.com/schema-refs-absolute-uris-defs1.json",
|
|
"properties": {
|
|
"foo": {
|
|
"$id": "http://example.com/schema-refs-absolute-uris-defs2.json",
|
|
"definitions": {
|
|
"inner": {
|
|
"properties": {
|
|
"bar": { "type": "string" }
|
|
}
|
|
}
|
|
},
|
|
"allOf": [ { "$ref": "#/definitions/inner" } ]
|
|
}
|
|
},
|
|
"allOf": [ { "$ref": "schema-refs-absolute-uris-defs2.json" } ]
|
|
},
|
|
"tests": [
|
|
{
|
|
"description": "invalid on inner field",
|
|
"data": {
|
|
"foo": {
|
|
"bar": 1
|
|
},
|
|
"bar": "a"
|
|
},
|
|
"valid": false
|
|
},
|
|
{
|
|
"description": "invalid on outer field",
|
|
"data": {
|
|
"foo": {
|
|
"bar": "a"
|
|
},
|
|
"bar": 1
|
|
},
|
|
"valid": false
|
|
},
|
|
{
|
|
"description": "valid on both fields",
|
|
"data": {
|
|
"foo": {
|
|
"bar": "a"
|
|
},
|
|
"bar": "a"
|
|
},
|
|
"valid": true
|
|
}
|
|
]
|
|
}
|
|
]
|