mirror of https://github.com/zulip/zulip.git
check-openapi: Remove check_duplicate_operation_ids.
This is handled by swagger-parser now. Signed-off-by: Anders Kaseorg <anders@zulipchat.com>
This commit is contained in:
parent
59c2b6dcc7
commit
7bbbc46aad
|
@ -2,42 +2,17 @@
|
|||
|
||||
const SwaggerParser = require('swagger-parser');
|
||||
|
||||
function check_duplicate_operationids(file, api) {
|
||||
const operation_ids = [];
|
||||
|
||||
for (const endpoint of api.paths) {
|
||||
for (const value of endpoint) {
|
||||
const operation_id = value.operationId;
|
||||
if (operation_id !== undefined) {
|
||||
if (operation_ids.includes(operation_id)) {
|
||||
console.error('In', file + ':');
|
||||
console.error('Duplicate operationId:', operation_id);
|
||||
process.exitCode = 1;
|
||||
} else {
|
||||
operation_ids.push(operation_id);
|
||||
}
|
||||
}
|
||||
}
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
function validate_swagger(file) {
|
||||
SwaggerParser.validate(file)
|
||||
.then(function (api) {
|
||||
// Let's make sure that there aren't any duplicate operationids,
|
||||
// until this issue is fixed:
|
||||
// https://github.com/BigstickCarpet/swagger-parser/issues/68
|
||||
check_duplicate_operationids(file, api);
|
||||
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.
|
||||
|
|
Loading…
Reference in New Issue