Skip to content
Snippets Groups Projects
Commit a1913e4b authored by Vincenzo Chianese's avatar Vincenzo Chianese Committed by Alvaro Cabrera Durán
Browse files

fix: do not remove shared required properties in allOf selection (#524)

* fix: do not remove shared required properties

* test: add test
parent 75e69e77
Branches
Tags
No related merge requests found
File suppressed by a .gitattributes entry or the file's encoding is unsupported.
File suppressed by a .gitattributes entry or the file's encoding is unsupported.
File suppressed by a .gitattributes entry or the file's encoding is unsupported.
File suppressed by a .gitattributes entry or the file's encoding is unsupported.
File suppressed by a .gitattributes entry or the file's encoding is unsupported.
File suppressed by a .gitattributes entry or the file's encoding is unsupported.
......@@ -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];
});
}
......
[
{
"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"
]
}
]
}
]
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment