Skip to content

Commit

Permalink
Add validation for properties.something.type == array
Browse files Browse the repository at this point in the history
Specifically for 'type=array', but no 'items'
  • Loading branch information
ponelat committed Sep 19, 2017
1 parent e5cf86f commit 0a9accb
Showing 1 changed file with 9 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,15 @@ export function validate({ resolvedSpec }) {
}
}

if(path[path.length - 2] === "properties") {
if(obj.type === "array" && typeof obj.items !== "object") {
errors.push({
path,
message: "Model properties with 'array' type require an 'items' property"
})
}
}

if(Object.keys(obj).length) {
return Object.keys(obj).map(k => walk(obj[k], [...path, k]))

Expand Down

0 comments on commit 0a9accb

Please sign in to comment.