alterschema
Version:
Convert between schema specifications
154 lines (153 loc) • 3.5 kB
JSON
[
{
"name": "draft7 $schema",
"schema": {
"$schema": "http://json-schema.org/draft-07/schema#"
},
"expected": {
"$schema": "https://json-schema.org/draft/2019-09/schema"
}
},
{
"name": "draft7 $id with # to $anchor",
"schema": {
"$schema": "http://json-schema.org/draft-07/schema#",
"$id": "#tag"
},
"expected": {
"$schema": "https://json-schema.org/draft/2019-09/schema",
"$anchor": "tag"
}
},
{
"name": "draft7 definitions",
"schema": {
"$schema": "http://json-schema.org/draft-07/schema#",
"properties": {
"foo": {
"$ref": "#/definitions/foo"
}
},
"definitions": {
"foo": { "type": "string" }
}
},
"expected": {
"$schema": "https://json-schema.org/draft/2019-09/schema",
"properties": {
"foo": {
"$ref": "#/$defs/foo"
}
},
"$defs": {
"foo": { "type": "string" }
}
}
},
{
"name": "true no metaschema",
"schema": {},
"expected": true
},
{
"name": "true no metaschema",
"schema": { "not": {} },
"expected": false
},
{
"name": "enum with one value",
"schema": {
"$schema": "http://json-schema.org/draft-07/schema#",
"enum": [ "single-value" ]
},
"expected": {
"$schema": "https://json-schema.org/draft/2019-09/schema",
"const": "single-value"
}
},
{
"name": "dependencies to dependentRequired and dependentSchemas",
"schema": {
"$schema": "http://json-schema.org/draft-07/schema#",
"dependencies": {
"foo": { "type": "string" },
"bar": false,
"baz": true,
"qux": [ "foo" ]
}
},
"expected": {
"$schema": "https://json-schema.org/draft/2019-09/schema",
"dependentSchemas": {
"foo": { "type": "string" },
"bar": false,
"baz": true
},
"dependentRequired": {
"qux": [ "foo" ]
}
}
},
{
"name": "dependencies to dependentSchemas only",
"schema": {
"$schema": "http://json-schema.org/draft-07/schema#",
"dependencies": {
"foo": { "type": "string" },
"bar": false,
"baz": true
}
},
"expected": {
"$schema": "https://json-schema.org/draft/2019-09/schema",
"dependentSchemas": {
"foo": { "type": "string" },
"bar": false,
"baz": true
}
}
},
{
"name": "dependencies to dependentRequired only",
"schema": {
"$schema": "http://json-schema.org/draft-07/schema#",
"dependencies": {
"qux": [ "foo" ]
}
},
"expected": {
"$schema": "https://json-schema.org/draft/2019-09/schema",
"dependentRequired": {
"qux": [ "foo" ]
}
}
},
{
"name": "enum with multiple elements is preserved",
"schema": {
"$schema": "http://json-schema.org/draft-07/schema#",
"enum": [ "foo", "bar" ]
},
"expected": {
"$schema": "https://json-schema.org/draft/2019-09/schema",
"enum": [ "foo", "bar" ]
}
},
{
"name": "properties with a not: {} schema",
"schema": {
"$schema": "http://json-schema.org/draft-07/schema#",
"properties": {
"foo": {
"not": {}
}
}
},
"expected": {
"$schema": "https://json-schema.org/draft/2019-09/schema",
"properties": {
"foo": false
}
}
}
]