From 235d3fc9fa9c1ed006ccd14a7257db455cd01494 Mon Sep 17 00:00:00 2001 From: VijayKesharwani <122533719+VijayKesharwani@users.noreply.github.com> Date: Tue, 31 Oct 2023 19:48:03 +0530 Subject: [PATCH] Update camara-casing-convention.js --- lint_function/camara-casing-convention.js | 22 ++++------------------ 1 file changed, 4 insertions(+), 18 deletions(-) diff --git a/lint_function/camara-casing-convention.js b/lint_function/camara-casing-convention.js index fd18280394..092dd0b4d1 100644 --- a/lint_function/camara-casing-convention.js +++ b/lint_function/camara-casing-convention.js @@ -1,34 +1,20 @@ // lint_function/camara-casing-convention.js - export default async function (input) { const errors = []; const suggestions = []; - // Iterate over the paths in the API definition - for (const path in input.paths) { - for (const method in input.paths[path]) { - const operation = input.paths[path][method]; - if (operation.operationId) { - const operationId = operation.operationId; - // Check if operationId is not in camelCase - if (!isCamelCase(operationId)) { - errors.push(operationId); - suggestions.push(`OperationId '${operationId}' should be in camelCase.`); - } - } else { - errors.push('OperationId missing'); - suggestions.push(`OperationId is missing for the ${method} operation on path '${path}'.`); - } + for (const operationId of input) { + if (!isCamelCase(operationId)) { + errors.push(operationId); + suggestions.push(`OperationId '${operationId}' should be in camelCase.`); } } - // Check if any errors were found if (errors.length > 0) { console.log('Hint: OperationId casing convention issues found: ' + suggestions.join(', ')); } } function isCamelCase(str) { - // Check if a string is in camelCase return /^[a-z][a-zA-Z0-9]*$/.test(str); }