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.`); + } + } + } + } +};