diff --git a/tools/spectral/ipa/__tests__/IPA005ExceptionExtensionFormat.test.js b/tools/spectral/ipa/__tests__/IPA005ExceptionExtensionFormat.test.js index fda9121389..7e2f3a1f18 100644 --- a/tools/spectral/ipa/__tests__/IPA005ExceptionExtensionFormat.test.js +++ b/tools/spectral/ipa/__tests__/IPA005ExceptionExtensionFormat.test.js @@ -16,11 +16,22 @@ testRule('xgen-IPA-005-exception-extension-format', [ 'xgen-IPA-100': 'Exception.', }, }, + '/path-camelCase': { + 'x-xgen-IPA-exception': { + 'xgen-IPA-125-rule-name-camelCase': 'Exception.', + }, + }, + '/path-numbers': { + 'x-xgen-IPA-exception': { + 'xgen-IPA-117-rule-name-1': 'Exception.', + }, + }, '/nested': { post: { 'x-xgen-IPA-exception': { 'xgen-IPA-100-rule-name': 'Exception.', 'xgen-IPA-005': 'Short format exception.', + 'xgen-IPA-112-camelCase': 'CamelCase exception.', }, }, }, diff --git a/tools/spectral/ipa/rulesets/IPA-005.yaml b/tools/spectral/ipa/rulesets/IPA-005.yaml index dbe38f99e4..3f4fc8e7d7 100644 --- a/tools/spectral/ipa/rulesets/IPA-005.yaml +++ b/tools/spectral/ipa/rulesets/IPA-005.yaml @@ -11,8 +11,9 @@ rules: ##### Implementation details Rule checks for the following conditions: - - Exception rule names must start with 'xgen-IPA-' prefix + - Exception rule names must start with 'xgen-IPA-' prefix followed by exactly 3 digits - Exception rule names can be either short format (xgen-IPA-XXX) or full format (xgen-IPA-XXX-rule-name) + - Rule names in full format can use letters (upper/lowercase), numbers, and hyphens - Each exception must include a non-empty reason as a string that starts with uppercase and ends with a full stop - This rule itself does not allow exceptions message: '{{error}} https://mdb.link/mongodb-atlas-openapi-validation#xgen-IPA-005-exception-extension-format' diff --git a/tools/spectral/ipa/rulesets/README.md b/tools/spectral/ipa/rulesets/README.md index ee51880aae..01a568fca8 100644 --- a/tools/spectral/ipa/rulesets/README.md +++ b/tools/spectral/ipa/rulesets/README.md @@ -19,8 +19,9 @@ IPA exception extensions must follow the correct format. ##### Implementation details Rule checks for the following conditions: - - Exception rule names must start with 'xgen-IPA-' prefix + - Exception rule names must start with 'xgen-IPA-' prefix followed by exactly 3 digits - Exception rule names can be either short format (xgen-IPA-XXX) or full format (xgen-IPA-XXX-rule-name) + - Rule names in full format can use letters (upper/lowercase), numbers, and hyphens - Each exception must include a non-empty reason as a string that starts with uppercase and ends with a full stop - This rule itself does not allow exceptions diff --git a/tools/spectral/ipa/rulesets/functions/IPA005ExceptionExtensionFormat.js b/tools/spectral/ipa/rulesets/functions/IPA005ExceptionExtensionFormat.js index 0d320ca630..a8ab36c386 100644 --- a/tools/spectral/ipa/rulesets/functions/IPA005ExceptionExtensionFormat.js +++ b/tools/spectral/ipa/rulesets/functions/IPA005ExceptionExtensionFormat.js @@ -4,7 +4,7 @@ const ERROR_MESSAGE_RULENAME_FORMAT = 'IPA exceptions must have a valid key following xgen-IPA-XXX or xgen-IPA-XXX-{rule-name} format.'; const ERROR_MESSAGE_REASON_FORMAT = 'IPA exceptions must have a non-empty reason that starts with uppercase and ends with a full stop.'; -const RULE_NAME_PATTERN = /^xgen-IPA-\d{3}(?:-[a-z-]+)?$/; +const RULE_NAME_PATTERN = /^xgen-IPA-\d{3}(?:-[a-zA-Z0-9-]+)?$/; // Note: This rule does not allow exceptions export default (input, _, { path, rule }) => {