diff --git a/dist/bundle.umd.min.js b/dist/bundle.umd.min.js index 848748539616e0d5c24954896e58387f6a865432..c4d89ff3a7ee3bb434b35695297d2062d700f8f2 100644 Binary files a/dist/bundle.umd.min.js and b/dist/bundle.umd.min.js differ diff --git a/dist/index.esm.js b/dist/index.esm.js index 35ead862e388d8573bf9e467f13e834703ec3566..8aab5fe752f920ca0742812513a3e717930ea9af 100644 Binary files a/dist/index.esm.js and b/dist/index.esm.js differ diff --git a/dist/index.js b/dist/index.js index b64016d42e47cf6e4775659ba0e60e93fbed9534..8d05375d63a343539b2121754898e26149998a1a 100644 Binary files a/dist/index.js and b/dist/index.js differ diff --git a/dist/index.umd.js b/dist/index.umd.js index 17023b7c16afeabf1cfdbef77f5a31bb8849dbb8..149b6ef75ff23c141d7f6662e404953cd9e39e99 100644 Binary files a/dist/index.umd.js and b/dist/index.umd.js differ diff --git a/dist/index.umd.min.js b/dist/index.umd.min.js index bfbb5052724591f8bac839b191f89f7bdb6927c1..ea5aa55bdb7ffe8b9724f3931df524e9d9a0fcec 100644 Binary files a/dist/index.umd.min.js and b/dist/index.umd.min.js differ diff --git a/dist/index.umd.min.js.map b/dist/index.umd.min.js.map index ffd4bef441cfa98be8a9e9378254f3a4b68aefd7..cd29ca7a5e9c53f9c491b3f1538f9f60bb7d465d 100644 Binary files a/dist/index.umd.min.js.map and b/dist/index.umd.min.js.map differ diff --git a/src/core/run.js b/src/core/run.js index 430f8dc4a8d07be87414d827a11c342ce10f0d64..23ac43e89829fd6e51974db6ac47e4d80755760f 100644 --- a/src/core/run.js +++ b/src/core/run.js @@ -169,7 +169,7 @@ function run(refs, schema, container) { if (sub.oneOf) { mix.forEach(omit => { if (omit !== fixed && omit.required) { - omit.required.forEach(key => { + omit.required.filter(required => !fixed.required.includes(required)).forEach(function (key) { delete copy.properties[key]; }); } diff --git a/tests/schema/core/required/do-not-delete-shared-props.json b/tests/schema/core/required/do-not-delete-shared-props.json new file mode 100644 index 0000000000000000000000000000000000000000..d9c80973799e14074e00a14550ad3607cb7fde74 --- /dev/null +++ b/tests/schema/core/required/do-not-delete-shared-props.json @@ -0,0 +1,69 @@ +[ + { + "description": "when allOf is provided and all the schemas are sharing some required properties", + "tests": [ + { + "description": "should not remove the shared properties", + "schema": { + "type": "object", + "oneOf": [ + { + "$ref": "#/components/A" + }, + { + "$ref": "#/components/B" + } + ], + "components": { + "A": { + "required": [ + "name", + "resourceType" + ], + "type": "object", + "properties": { + "resourceType": { + "type": "string" + }, + "name": { + "type": "string" + }, + "color": { + "type": "string" + }, + "length": { + "type": "integer" + } + } + }, + "B": { + "required": [ + "name", + "resourceType" + ], + "type": "object", + "properties": { + "resourceType": { + "type": "string" + }, + "name": { + "type": "string" + }, + "description": { + "type": "string" + }, + "age": { + "type": "integer" + } + } + } + } + }, + "hasProps": [ + "name", + "resourceType" + ] + } + ] + } +]