From 6128afb3c9d98a90d6c4e1d07236b1f7287837f4 Mon Sep 17 00:00:00 2001 From: VijayKesharwani <122533719+VijayKesharwani@users.noreply.github.com> Date: Tue, 31 Oct 2023 14:27:52 +0530 Subject: [PATCH] Create camara-casing-convention.js --- lint_function/camara-casing-convention.js | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 lint_function/camara-casing-convention.js diff --git a/lint_function/camara-casing-convention.js b/lint_function/camara-casing-convention.js new file mode 100644 index 0000000000..297f1f775f --- /dev/null +++ b/lint_function/camara-casing-convention.js @@ -0,0 +1,19 @@ +function isCamelCase(str) { + // Regular expression to match valid camel case identifiers + const camelCaseRegex = /^[a-z][a-zA-Z0-9]*$/; + return camelCaseRegex.test(str); +} + +export default async function (input) { + for (const path in input.paths) { + const pathObject = input.paths[path]; + for (const method in pathObject) { + const operation = pathObject[method]; + if (operation.operationId) { + if (!isCamelCase(operation.operationId)) { + console.warn(`WARN: Operation ID "${operation.operationId}" in path "${path}" does not follow camel case convention.`); + } + } + } + } +};