mirror of https://github.com/zulip/zulip.git
lint: Add validation for the Swagger file.
This commit is contained in:
parent
99b004942f
commit
9602f73d05
|
@ -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"
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
|
@ -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:
|
||||
|
|
|
@ -1,2 +1,2 @@
|
|||
ZULIP_VERSION = "1.5.1+git"
|
||||
PROVISION_VERSION = '5.3'
|
||||
PROVISION_VERSION = '5.4'
|
||||
|
|
Loading…
Reference in New Issue