Skip to content
Snippets Groups Projects
Commit 5df8f20c authored by hackerman's avatar hackerman Committed by Alvaro Cabrera Durán
Browse files

Resolve issue with required field in oneOf (#534)

Having a schema that has a oneOf definition as such:

```
{
  "oneOf": [
    { required: ["foo"], /*...*/ },
    { /*...*/ },
  ]
}
```

causes the changed line to fail with error message `calling includes on undefined`. This does not always happen, as it appears that the "oneOf" field is being picked by random.

This patch simply uses a default empty array if `fixed.required` is undefined, resolving this issue.
parent 2fd626ff
Branches
Tags
No related merge requests found
...@@ -169,7 +169,7 @@ function run(refs, schema, container) { ...@@ -169,7 +169,7 @@ function run(refs, schema, container) {
if (sub.oneOf) { if (sub.oneOf) {
mix.forEach(omit => { mix.forEach(omit => {
if (omit !== fixed && omit.required) { if (omit !== fixed && omit.required) {
omit.required.filter(required => !fixed.required.includes(required)).forEach(function (key) { omit.required.filter(required => !(fixed.required || []).includes(required)).forEach(function (key) {
delete copy.properties[key]; delete copy.properties[key];
}); });
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment