From 1ddd6f62d31cff974f9248d6d41aea2ab61ef028 Mon Sep 17 00:00:00 2001 From: Yeliz Henden Date: Fri, 5 Sep 2025 11:33:07 +0100 Subject: [PATCH 1/3] fix(ipa): Fix IPA005 rule to allow camel case and numbers in rule name --- .../__tests__/IPA005ExceptionExtensionFormat.test.js | 11 +++++++++++ tools/spectral/ipa/rulesets/IPA-005.yaml | 3 ++- .../functions/IPA005ExceptionExtensionFormat.js | 7 +++++-- 3 files changed, 18 insertions(+), 3 deletions(-) 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/functions/IPA005ExceptionExtensionFormat.js b/tools/spectral/ipa/rulesets/functions/IPA005ExceptionExtensionFormat.js index 0d320ca630..8d974d81d1 100644 --- a/tools/spectral/ipa/rulesets/functions/IPA005ExceptionExtensionFormat.js +++ b/tools/spectral/ipa/rulesets/functions/IPA005ExceptionExtensionFormat.js @@ -1,10 +1,13 @@ -import { evaluateAndCollectAdoptionStatusWithoutExceptions, handleInternalError } from './utils/collectionUtils.js'; +import { + evaluateAndCollectAdoptionStatusWithoutExceptions, + handleInternalError, +} from './utils/collectionUtils.js'; 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 }) => { From 1f57a5f1b3a262dcd6223334d58e29433d4d9e4b Mon Sep 17 00:00:00 2001 From: Yeliz Henden Date: Fri, 5 Sep 2025 11:45:27 +0100 Subject: [PATCH 2/3] prettier fix --- .../ipa/rulesets/functions/IPA005ExceptionExtensionFormat.js | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/tools/spectral/ipa/rulesets/functions/IPA005ExceptionExtensionFormat.js b/tools/spectral/ipa/rulesets/functions/IPA005ExceptionExtensionFormat.js index 8d974d81d1..a8ab36c386 100644 --- a/tools/spectral/ipa/rulesets/functions/IPA005ExceptionExtensionFormat.js +++ b/tools/spectral/ipa/rulesets/functions/IPA005ExceptionExtensionFormat.js @@ -1,7 +1,4 @@ -import { - evaluateAndCollectAdoptionStatusWithoutExceptions, - handleInternalError, -} from './utils/collectionUtils.js'; +import { evaluateAndCollectAdoptionStatusWithoutExceptions, handleInternalError } from './utils/collectionUtils.js'; const ERROR_MESSAGE_RULENAME_FORMAT = 'IPA exceptions must have a valid key following xgen-IPA-XXX or xgen-IPA-XXX-{rule-name} format.'; From fc81ce99757d2fc6120410db1fd876db511dd91c Mon Sep 17 00:00:00 2001 From: Yeliz Henden Date: Fri, 5 Sep 2025 11:46:44 +0100 Subject: [PATCH 3/3] ipa docs gen fix --- tools/spectral/ipa/rulesets/README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) 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