Skip to content

Commit

Permalink
Merge pull request #1495 from swagger-api/feature/validation-array-re…
Browse files Browse the repository at this point in the history
…quire-items

Add validation for properties.something.type == array
  • Loading branch information
ponelat authored Sep 19, 2017
2 parents e5cf86f + 0a9accb commit c238306
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 c238306

Please sign in to comment.