From 7bbbc46aad2256a04b4708c4b82cc6c7887b69d5 Mon Sep 17 00:00:00 2001 From: Anders Kaseorg Date: Fri, 17 Apr 2020 15:01:59 -0700 Subject: [PATCH] check-openapi: Remove check_duplicate_operation_ids. This is handled by swagger-parser now. Signed-off-by: Anders Kaseorg --- tools/check-openapi | 41 ++++++++--------------------------------- 1 file changed, 8 insertions(+), 33 deletions(-) diff --git a/tools/check-openapi b/tools/check-openapi index ee4ee01401..6a75d25add 100755 --- a/tools/check-openapi +++ b/tools/check-openapi @@ -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.