diff --git a/rules/from-draft3/to-draft4/013-type-has-objects-and-strings-in-its-array-initialize.json b/rules/from-draft3/to-draft4/013-type-has-objects-and-strings-in-its-array-initialize.json index db343bd..f8596ec 100644 --- a/rules/from-draft3/to-draft4/013-type-has-objects-and-strings-in-its-array-initialize.json +++ b/rules/from-draft3/to-draft4/013-type-has-objects-and-strings-in-its-array-initialize.json @@ -7,6 +7,7 @@ { "operation": "contains-type", "path": [ "type" ], "value": "string" } ], "transform": [ - { "operation": "add", "path": [ "anyOf", "-" ], "value": { "type": [] } } + { "operation": "add", "path": [ "anyOf", "-" ], "value": { "type": [] } }, + { "operation": "add", "path": [ "type", "-" ], "value": true } ] } diff --git a/rules/from-draft3/to-draft4/014-type-has-objects-and-strings-in-its-array.json b/rules/from-draft3/to-draft4/014-type-has-objects-and-strings-in-its-array.json index 5f69a32..9140836 100644 --- a/rules/from-draft3/to-draft4/014-type-has-objects-and-strings-in-its-array.json +++ b/rules/from-draft3/to-draft4/014-type-has-objects-and-strings-in-its-array.json @@ -7,6 +7,6 @@ { "operation": "type-is", "path": [ "type", {} ], "value": "string" } ], "transform": [ - { "operation": "remove-and-append", "to": [ "anyOf", "-", "type" ], "from": [ "type", {} ] } + { "operation": "copy", "to": [ "anyOf", "-", "type", "-" ], "from": [ "type", {} ] } ] } diff --git a/rules/from-draft3/to-draft4/016-type-has-objects-and-strings-in-its-array.json b/rules/from-draft3/to-draft4/016-type-has-objects-and-strings-in-its-array.json new file mode 100644 index 0000000..6f7b851 --- /dev/null +++ b/rules/from-draft3/to-draft4/016-type-has-objects-and-strings-in-its-array.json @@ -0,0 +1,12 @@ +{ + "vocabulary": "core", + "condition": [ + { "operation": "has-key", "path": [], "value": "type" }, + { "operation": "type-is", "path": [ "type" ], "value": "array" }, + { "operation": "contains-type", "path": [ "type" ], "value": "object" }, + { "operation": "type-is", "path": [ "type", {} ], "value": "string" } + ], + "transform": [ + { "operation": "remove", "path": [ "type", {} ] } + ] +} diff --git a/rules/from-draft3/to-draft4/017-type-has-boolean-in-its-array.json b/rules/from-draft3/to-draft4/017-type-has-boolean-in-its-array.json new file mode 100644 index 0000000..db34e12 --- /dev/null +++ b/rules/from-draft3/to-draft4/017-type-has-boolean-in-its-array.json @@ -0,0 +1,11 @@ +{ + "vocabulary": "core", + "condition": [ + { "operation": "has-key", "path": [], "value": "type" }, + { "operation": "type-is", "path": [ "type" ], "value": "array" }, + { "operation": "contains-type", "path": [ "type" ], "value": "boolean" } + ], + "transform": [ + { "operation": "remove", "path": [ "type" ] } + ] +} diff --git a/rules/from-draft3/to-draft4/016-type-is-an-empty-array.json b/rules/from-draft3/to-draft4/017-type-is-an-empty-array.json similarity index 100% rename from rules/from-draft3/to-draft4/016-type-is-an-empty-array.json rename to rules/from-draft3/to-draft4/017-type-is-an-empty-array.json diff --git a/rules/from-draft3/to-draft4/017-disallow-has-value-equals-any.json b/rules/from-draft3/to-draft4/018-disallow-has-value-equals-any.json similarity index 100% rename from rules/from-draft3/to-draft4/017-disallow-has-value-equals-any.json rename to rules/from-draft3/to-draft4/018-disallow-has-value-equals-any.json diff --git a/rules/from-draft3/to-draft4/018-disallow-has-any-in-its-array.json b/rules/from-draft3/to-draft4/019-disallow-has-any-in-its-array.json similarity index 100% rename from rules/from-draft3/to-draft4/018-disallow-has-any-in-its-array.json rename to rules/from-draft3/to-draft4/019-disallow-has-any-in-its-array.json diff --git a/rules/from-draft3/to-draft4/019-disallow-has-atleast-one-object-in-its-array-initialize-allOf.json b/rules/from-draft3/to-draft4/020-disallow-has-atleast-one-object-in-its-array-initialize-allOf.json similarity index 100% rename from rules/from-draft3/to-draft4/019-disallow-has-atleast-one-object-in-its-array-initialize-allOf.json rename to rules/from-draft3/to-draft4/020-disallow-has-atleast-one-object-in-its-array-initialize-allOf.json diff --git a/rules/from-draft3/to-draft4/020-disallow-has-atleast-one-object-in-its-array.json b/rules/from-draft3/to-draft4/021-disallow-has-atleast-one-object-in-its-array.json similarity index 100% rename from rules/from-draft3/to-draft4/020-disallow-has-atleast-one-object-in-its-array.json rename to rules/from-draft3/to-draft4/021-disallow-has-atleast-one-object-in-its-array.json diff --git a/rules/from-draft3/to-draft4/021-disallow-is-an-array-of-strings-allOf-present.json b/rules/from-draft3/to-draft4/022-disallow-is-an-array-of-strings-allOf-present.json similarity index 100% rename from rules/from-draft3/to-draft4/021-disallow-is-an-array-of-strings-allOf-present.json rename to rules/from-draft3/to-draft4/022-disallow-is-an-array-of-strings-allOf-present.json diff --git a/rules/from-draft3/to-draft4/022-disallow-is-an-array-of-strings-allOf-absent.json b/rules/from-draft3/to-draft4/023-disallow-is-an-array-of-strings-allOf-absent.json similarity index 100% rename from rules/from-draft3/to-draft4/022-disallow-is-an-array-of-strings-allOf-absent.json rename to rules/from-draft3/to-draft4/023-disallow-is-an-array-of-strings-allOf-absent.json diff --git a/rules/from-draft3/to-draft4/023-disallow-is-an-empty-array.json b/rules/from-draft3/to-draft4/024-disallow-is-an-empty-array.json similarity index 100% rename from rules/from-draft3/to-draft4/023-disallow-is-an-empty-array.json rename to rules/from-draft3/to-draft4/024-disallow-is-an-empty-array.json diff --git a/rules/from-draft3/to-draft4/024-dependencies-children-have-type-string.json b/rules/from-draft3/to-draft4/025-dependencies-children-have-type-string.json similarity index 100% rename from rules/from-draft3/to-draft4/024-dependencies-children-have-type-string.json rename to rules/from-draft3/to-draft4/025-dependencies-children-have-type-string.json diff --git a/rules/from-draft3/to-draft4/025-divisiblyBy.json b/rules/from-draft3/to-draft4/026-divisiblyBy.json similarity index 100% rename from rules/from-draft3/to-draft4/025-divisiblyBy.json rename to rules/from-draft3/to-draft4/026-divisiblyBy.json diff --git a/rules/from-draft3/to-draft4/026-extends-is-an-array-allOf-absent.json b/rules/from-draft3/to-draft4/027-extends-is-an-array-allOf-absent.json similarity index 83% rename from rules/from-draft3/to-draft4/026-extends-is-an-array-allOf-absent.json rename to rules/from-draft3/to-draft4/027-extends-is-an-array-allOf-absent.json index e55a5ff..fa78bfd 100644 --- a/rules/from-draft3/to-draft4/026-extends-is-an-array-allOf-absent.json +++ b/rules/from-draft3/to-draft4/027-extends-is-an-array-allOf-absent.json @@ -7,6 +7,6 @@ { "operation": "not-has-key", "path": [], "value": "allOf" } ], "transform": [ - { "operation": "move", "to": [ "allOf" ], "from": [ "extends" ] } + { "operation": "add", "path": [ "allOf" ], "value": [] } ] } diff --git a/rules/from-draft3/to-draft4/027-extends-is-an-array-allOf-present.json b/rules/from-draft3/to-draft4/028-extends-is-an-array-allOf-present.json similarity index 100% rename from rules/from-draft3/to-draft4/027-extends-is-an-array-allOf-present.json rename to rules/from-draft3/to-draft4/028-extends-is-an-array-allOf-present.json diff --git a/rules/from-draft3/to-draft4/028-extends-is-an-object-allOf-absent.json b/rules/from-draft3/to-draft4/029-extends-is-an-object-allOf-absent.json similarity index 100% rename from rules/from-draft3/to-draft4/028-extends-is-an-object-allOf-absent.json rename to rules/from-draft3/to-draft4/029-extends-is-an-object-allOf-absent.json diff --git a/rules/from-draft3/to-draft4/029-extends-is-an-object-allOf-present.json b/rules/from-draft3/to-draft4/030-extends-is-an-object-allOf-present.json similarity index 100% rename from rules/from-draft3/to-draft4/029-extends-is-an-object-allOf-present.json rename to rules/from-draft3/to-draft4/030-extends-is-an-object-allOf-present.json diff --git a/rules/from-draft3/to-draft4/030-empty-extends-array.json b/rules/from-draft3/to-draft4/031-empty-extends-array.json similarity index 100% rename from rules/from-draft3/to-draft4/030-empty-extends-array.json rename to rules/from-draft3/to-draft4/031-empty-extends-array.json diff --git a/rules/from-draft3/to-draft4/031-required-false-present-in-properties's-values.json b/rules/from-draft3/to-draft4/032-required-false-present-in-properties's-values.json similarity index 100% rename from rules/from-draft3/to-draft4/031-required-false-present-in-properties's-values.json rename to rules/from-draft3/to-draft4/032-required-false-present-in-properties's-values.json diff --git a/rules/from-draft3/to-draft4/032-required-is-present-in-outer-schema.json b/rules/from-draft3/to-draft4/033-required-is-present-in-outer-schema.json similarity index 100% rename from rules/from-draft3/to-draft4/032-required-is-present-in-outer-schema.json rename to rules/from-draft3/to-draft4/033-required-is-present-in-outer-schema.json diff --git a/rules/from-draft3/to-draft4/033-required-is-absent-and-required-true-in-properties.json b/rules/from-draft3/to-draft4/034-required-is-absent-in-outer-schema-and-required-true-in-properties.json similarity index 100% rename from rules/from-draft3/to-draft4/033-required-is-absent-and-required-true-in-properties.json rename to rules/from-draft3/to-draft4/034-required-is-absent-in-outer-schema-and-required-true-in-properties.json diff --git a/rules/from-draft3/to-draft4/034-required-true-present-in-properties's-values.json b/rules/from-draft3/to-draft4/035-required-true-present-in-properties's-values.json similarity index 100% rename from rules/from-draft3/to-draft4/034-required-true-present-in-properties's-values.json rename to rules/from-draft3/to-draft4/035-required-true-present-in-properties's-values.json diff --git a/rules/from-draft3/to-draft4/035-empty-required-array-in-outer-schema.json b/rules/from-draft3/to-draft4/036-empty-required-array-in-outer-schema.json similarity index 100% rename from rules/from-draft3/to-draft4/035-empty-required-array-in-outer-schema.json rename to rules/from-draft3/to-draft4/036-empty-required-array-in-outer-schema.json diff --git a/test/from-2019-09/to-2020-12/references-tweak.json b/test/from-2019-09/to-2020-12/references-tweak.json new file mode 100644 index 0000000..d43579a --- /dev/null +++ b/test/from-2019-09/to-2020-12/references-tweak.json @@ -0,0 +1,76 @@ +[ + { + "title": "Reference to contains", + "from": { + "$ref": "#/contains", + "contains": { + "type": "string" + } + }, + "to": { + "$ref": "#/allOf/0/not/not/contains", + "allOf": [ + { + "not": { + "not": { + "contains": { + "type": "string" + } + } + } + } + ] + } + }, + { + "title":"Reference to items is an array", + "from": { + "$ref": "#/items/0", + "items": [ + { + "type": "string" + } + ] + }, + "to": { + "$ref": "#/prefixItems/0", + "prefixItems": [ + { + "type": "string" + } + ] + } + }, + { + "title":"Reference to items is an object", + "from": { + "$ref": "#/items", + "items": { + "type": "string" + } + }, + "to": { + "$ref": "#/items", + "items": { + "type": "string" + } + } + }, + { + "title":"Reference to additionalItems is an object, items is an array", + "from": { + "$ref": "#/additionalItems", + "items": [ {} ], + "additionalItems": { + "type": "string" + } + }, + "to": { + "$ref": "#/items", + "prefixItems": [ {} ], + "items": { + "type": "string" + } + } + } +] \ No newline at end of file diff --git a/test/from-draft3/to-draft4/references-tweak.json b/test/from-draft3/to-draft4/references-tweak.json new file mode 100644 index 0000000..53b259d --- /dev/null +++ b/test/from-draft3/to-draft4/references-tweak.json @@ -0,0 +1,141 @@ +[ + { + "title": "Reference to `type` when it has objects in its array", + "from": { + "type": [ {} ], + "properties": { + "foo": { + "$ref": "#/type/0" + } + } + }, + "to": { + "anyOf": [ + {} + ], + "properties": { + "foo": { + "$ref": "#/anyOf/0" + } + } + } + }, + { + "title": "Reference to `type` when it has objects and string in its array", + "from": { + "type": [ "string", {} ], + "properties": { + "foo": { + "$ref": "#/type/1" + } + } + }, + "to": { + "anyOf": [ + { "type": ["string"] }, + {} + ], + "properties": { + "foo": { + "$ref": "#/anyOf/1" + } + } + } + }, + { + "title":"Reference to `disallow` when it has objects in its array", + "from": { + "disallow": [ {} ], + "properties": { + "foo": { + "$ref": "#/disallow/0" + } + } + }, + "to": { + "allOf": [ + { "not": {} } + ], + "properties": { + "foo": { + "$ref": "#/allOf/0/not" + } + } + } + }, + { + "title": "Reference to `disallow` when it has objects and string in its array", + "from": { + "disallow": [ "string", {} ], + "properties": { + "foo": { + "$ref": "#/disallow/1" + } + } + }, + "to": { + "allOf": [ + { + "not": {} + }, + { + "not": { + "type": [ + "string" + ] + } + } + ], + "properties": { + "foo": { + "$ref": "#/allOf/0/not" + } + } + } + }, + { + "title": "Reference to `extends` when its an array", + "from": { + "extends": [ {}, { "type": "object" } ], + "properties": { + "foo": { + "$ref": "#/extends/0" + } + } + }, + "to": { + "allOf": [ + { + "type": "object" + }, + {} + ], + "properties": { + "foo": { + "$ref": "#/allOf/0" + } + } + } + }, + { + "title": "Reference to `extends` when its an object", + "from": { + "extends": {}, + "properties": { + "foo": { + "$ref": "#/extends" + } + } + }, + "to": { + "allOf": [ + {} + ], + "properties": { + "foo": { + "$ref": "#/allOf/0" + } + } + } + } +] diff --git a/test/from-draft7/to-2019-09/references-tweak.json b/test/from-draft7/to-2019-09/references-tweak.json new file mode 100644 index 0000000..4df7067 --- /dev/null +++ b/test/from-draft7/to-2019-09/references-tweak.json @@ -0,0 +1,52 @@ +[ + { + "title": "Reference to definitions", + "from": { + "allOf": [ + { + "$ref": "#/definitions/foo" + } + ], + "definitions": { + "foo": {} + } + }, + "to": { + "allOf": [ + { + "$ref": "#/$defs/foo" + } + ], + "$defs": { + "foo": {} + } + } + }, + { + "title": "Reference to dependencies, child is a schema", + "from": { + "allOf": [ + { + "$ref": "#/dependencies/foo" + } + ], + "dependencies": { + "foo": { + "type": "string" + } + } + }, + "to": { + "allOf": [ + { + "$ref": "#/dependentSchemas/foo" + } + ], + "dependentSchemas": { + "foo": { + "type": "string" + } + } + } + } +]