diff --git a/package.json b/package.json index 660d985d38..8f575e4850 100644 --- a/package.json +++ b/package.json @@ -39,6 +39,7 @@ "nwmatcher": "1.3.6", "phantomjs-prebuilt": "2.1.14", "svgo": "0.7.2", + "swagger-parser": "3.4.1", "tslint": "5.3.2", "webpack-dev-server": "2.4.1", "xmlhttprequest": "1.5.0" diff --git a/tools/check-swagger b/tools/check-swagger new file mode 100644 index 0000000000..6a2811a0b2 --- /dev/null +++ b/tools/check-swagger @@ -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); + } +} diff --git a/tools/lint b/tools/lint index f8499a0c74..e92a9fe00a 100755 --- a/tools/lint +++ b/tools/lint @@ -715,6 +715,7 @@ def run(): external_linter('puppet', ['puppet', 'parser', 'validate'], ['pp']) external_linter('templates', ['tools/check-templates'], ['handlebars', 'html']) external_linter('urls', ['tools/check-urls']) + external_linter('swagger', ['node', 'tools/check-swagger'], ['yaml']) # gitlint disabled until we can stabilize it more # if not options.no_gitlint: diff --git a/version.py b/version.py index 19e8ddb050..ab836808ce 100644 --- a/version.py +++ b/version.py @@ -1,2 +1,2 @@ ZULIP_VERSION = "1.5.1+git" -PROVISION_VERSION = '5.3' +PROVISION_VERSION = '5.4'