mirror of https://github.com/zulip/zulip.git
25 lines
742 B
JavaScript
Executable File
25 lines
742 B
JavaScript
Executable File
#!/usr/bin/env node
|
|
|
|
const SwaggerParser = require('swagger-parser');
|
|
|
|
async function validate_swagger(file) {
|
|
try {
|
|
await SwaggerParser.validate(file);
|
|
} catch (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 (const file of process.argv.slice(2)) {
|
|
// Run the validator only for YAML files inside static/swagger
|
|
if (file.startsWith('static/swagger')) {
|
|
validate_swagger(file);
|
|
}
|
|
}
|