lint: Add validation for the Swagger file.

This commit is contained in:
Yago González 2017-06-02 23:12:26 +02:00 committed by Tim Abbott
parent 99b004942f
commit 9602f73d05
4 changed files with 29 additions and 1 deletions

View File

@ -39,6 +39,7 @@
"nwmatcher": "1.3.6", "nwmatcher": "1.3.6",
"phantomjs-prebuilt": "2.1.14", "phantomjs-prebuilt": "2.1.14",
"svgo": "0.7.2", "svgo": "0.7.2",
"swagger-parser": "3.4.1",
"tslint": "5.3.2", "tslint": "5.3.2",
"webpack-dev-server": "2.4.1", "webpack-dev-server": "2.4.1",
"xmlhttprequest": "1.5.0" "xmlhttprequest": "1.5.0"

26
tools/check-swagger Normal file
View File

@ -0,0 +1,26 @@
var SwaggerParser = require('swagger-parser');
function validateSwagger(file) {
SwaggerParser.validate(file)
.then(function() {
// The validation passed, no need to say anything
return;
})
.catch(function(err) {
// There is something wrong. Display the validation errors
console.error('In', file + ':');
console.error(err.message);
process.exitCode = 1;
});
}
// Iterate through the changed files, passed in the arguments.
// The two first arguments are the call to the Node interpreter and this
// script, hence the starting point at 2.
for(var i = 2; i < process.argv.length; i++) {
var file = process.argv[i];
// Run the validator only for YAML files inside static/swagger
if(file.startsWith('static/swagger')) {
validateSwagger(file);
}
}

View File

@ -715,6 +715,7 @@ def run():
external_linter('puppet', ['puppet', 'parser', 'validate'], ['pp']) external_linter('puppet', ['puppet', 'parser', 'validate'], ['pp'])
external_linter('templates', ['tools/check-templates'], ['handlebars', 'html']) external_linter('templates', ['tools/check-templates'], ['handlebars', 'html'])
external_linter('urls', ['tools/check-urls']) external_linter('urls', ['tools/check-urls'])
external_linter('swagger', ['node', 'tools/check-swagger'], ['yaml'])
# gitlint disabled until we can stabilize it more # gitlint disabled until we can stabilize it more
# if not options.no_gitlint: # if not options.no_gitlint:

View File

@ -1,2 +1,2 @@
ZULIP_VERSION = "1.5.1+git" ZULIP_VERSION = "1.5.1+git"
PROVISION_VERSION = '5.3' PROVISION_VERSION = '5.4'