Skip to content

Commit

Permalink
feat: validate for null values in the api document, return an error
Browse files Browse the repository at this point in the history
  • Loading branch information
dpopp07 committed Apr 18, 2019
1 parent cbfcc05 commit cc53855
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/plugins/validation/2and3/semantic-validators/walker-ibm.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ module.exports.validate = function({ jsSpec }, config) {
config = config.walker;

walk(jsSpec, [], function(obj, path) {
// check for empty descriptions
if (obj.description !== undefined && obj.description !== null) {
const description = obj.description.toString();
if (description.length === 0 || !description.trim()) {
Expand All @@ -24,6 +25,16 @@ module.exports.validate = function({ jsSpec }, config) {
}
}
}

// check for and flag null values - they are not allowed by the spec and are likely mistakes
Object.keys(obj).forEach(key => {
if (obj[key] === null) {
result.error.push({
path: [...path, key],
message: 'Null values are not allowed for any property.'
});
}
});
});

return { errors: result.error, warnings: result.warning };
Expand Down

0 comments on commit cc53855

Please sign in to comment.