alterschema
Version:
Convert between schema specifications
213 lines (212 loc) • 5.01 kB
JSON
[
{
"name": "draft4 $schema",
"schema": {
"$schema": "http://json-schema.org/draft-04/schema#"
},
"expected": {
"$schema": "https://json-schema.org/draft/2019-09/schema"
}
},
{
"name": "draft4 id to $id",
"schema": {
"$schema": "http://json-schema.org/draft-04/schema#",
"id": "http://example.com/schema"
},
"expected": {
"$schema": "https://json-schema.org/draft/2019-09/schema",
"$id": "http://example.com/schema"
}
},
{
"name": "draft4 $id with # to $anchor",
"schema": {
"$schema": "http://json-schema.org/draft-04/schema#",
"$id": "#tag"
},
"expected": {
"$schema": "https://json-schema.org/draft/2019-09/schema",
"$anchor": "tag"
}
},
{
"name": "draft4 exclusiveMinimum to minimum",
"schema": {
"$schema": "http://json-schema.org/draft-04/schema#",
"minimum": 5,
"exclusiveMinimum": true
},
"expected": {
"$schema": "https://json-schema.org/draft/2019-09/schema",
"exclusiveMinimum": 5
}
},
{
"name": "draft4 exclusiveMaximum to maximum",
"schema": {
"$schema": "http://json-schema.org/draft-04/schema#",
"maximum": 5,
"exclusiveMaximum": true
},
"expected": {
"$schema": "https://json-schema.org/draft/2019-09/schema",
"exclusiveMaximum": 5
}
},
{
"name": "draft4 exclusiveMinimum false",
"schema": {
"$schema": "http://json-schema.org/draft-04/schema#",
"minimum": 5,
"exclusiveMinimum": false
},
"expected": {
"$schema": "https://json-schema.org/draft/2019-09/schema",
"minimum": 5
}
},
{
"name": "draft4 exclusiveMaximum false",
"schema": {
"$schema": "http://json-schema.org/draft-04/schema#",
"maximum": 5,
"exclusiveMaximum": false
},
"expected": {
"$schema": "https://json-schema.org/draft/2019-09/schema",
"maximum": 5
}
},
{
"name": "draft4 definitions",
"schema": {
"$schema": "http://json-schema.org/draft-04/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-04/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-04/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-04/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-04/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-04/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-04/schema#",
"properties": {
"foo": {
"not": {}
}
}
},
"expected": {
"$schema": "https://json-schema.org/draft/2019-09/schema",
"properties": {
"foo": false
}
}
}
]