From ad52670add2aaba485aa15072b1ea00b53b91b2d Mon Sep 17 00:00:00 2001 From: Yeliz Henden Date: Fri, 22 Aug 2025 18:03:50 +0100 Subject: [PATCH 1/9] fix(ipa): exception reason formatting --- .../IPA005ExceptionExtensionFormat.test.js | 18 ++++---- tools/spectral/ipa/rulesets/IPA-005.yaml | 2 +- .../IPA005ExceptionExtensionFormat.js | 43 +++++++++++++++---- 3 files changed, 45 insertions(+), 18 deletions(-) diff --git a/tools/spectral/ipa/__tests__/IPA005ExceptionExtensionFormat.test.js b/tools/spectral/ipa/__tests__/IPA005ExceptionExtensionFormat.test.js index 9b2dd5c9c8..40efcf75f3 100644 --- a/tools/spectral/ipa/__tests__/IPA005ExceptionExtensionFormat.test.js +++ b/tools/spectral/ipa/__tests__/IPA005ExceptionExtensionFormat.test.js @@ -8,13 +8,13 @@ testRule('xgen-IPA-005-exception-extension-format', [ paths: { '/path': { 'x-xgen-IPA-exception': { - 'xgen-IPA-100-rule-name': 'Exception', + 'xgen-IPA-100-rule-name': 'Exception.', }, }, '/nested': { post: { 'x-xgen-IPA-exception': { - 'xgen-IPA-100-rule-name': 'Exception', + 'xgen-IPA-100-rule-name': 'Exception.', }, }, }, @@ -51,26 +51,26 @@ testRule('xgen-IPA-005-exception-extension-format', [ errors: [ { code: 'xgen-IPA-005-exception-extension-format', - message: 'IPA exceptions must have a valid rule name and a reason.', + message: 'IPA exceptions must have a valid key with xgen-IPA- prefix.', path: ['paths', '/path1', 'x-xgen-IPA-exception'], severity: DiagnosticSeverity.Error, }, { code: 'xgen-IPA-005-exception-extension-format', - message: 'IPA exceptions must have a valid rule name and a reason.', - path: ['paths', '/path2', 'x-xgen-IPA-exception', 'xgen-IPA-100-rule-name'], + message: 'IPA exceptions must have a non-empty reason that starts with uppercase and ends with a full stop.', + path: ['paths', '/path2', 'x-xgen-IPA-exception'], severity: DiagnosticSeverity.Error, }, { code: 'xgen-IPA-005-exception-extension-format', - message: 'IPA exceptions must have a valid rule name and a reason.', - path: ['paths', '/path3', 'x-xgen-IPA-exception', 'invalid-rule-name'], + message: 'IPA exceptions must have a valid key with xgen-IPA- prefix.', + path: ['paths', '/path3', 'x-xgen-IPA-exception'], severity: DiagnosticSeverity.Error, }, { code: 'xgen-IPA-005-exception-extension-format', - message: 'IPA exceptions must have a valid rule name and a reason.', - path: ['paths', '/path4', 'x-xgen-IPA-exception', 'xgen-IPA-100-rule-name'], + message: 'IPA exceptions must have a non-empty reason that starts with uppercase and ends with a full stop.', + path: ['paths', '/path4', 'x-xgen-IPA-exception'], severity: DiagnosticSeverity.Error, }, ], diff --git a/tools/spectral/ipa/rulesets/IPA-005.yaml b/tools/spectral/ipa/rulesets/IPA-005.yaml index 98eda6bf77..fc36af00e6 100644 --- a/tools/spectral/ipa/rulesets/IPA-005.yaml +++ b/tools/spectral/ipa/rulesets/IPA-005.yaml @@ -12,7 +12,7 @@ rules: ##### Implementation details Rule checks for the following conditions: - Exception rule names must start with 'xgen-IPA-' prefix - - Each exception must include a non-empty reason as a string + - 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' severity: error diff --git a/tools/spectral/ipa/rulesets/functions/IPA005ExceptionExtensionFormat.js b/tools/spectral/ipa/rulesets/functions/IPA005ExceptionExtensionFormat.js index ac7c64377f..00fbe6ce1b 100644 --- a/tools/spectral/ipa/rulesets/functions/IPA005ExceptionExtensionFormat.js +++ b/tools/spectral/ipa/rulesets/functions/IPA005ExceptionExtensionFormat.js @@ -1,6 +1,10 @@ -import { evaluateAndCollectAdoptionStatusWithoutExceptions, handleInternalError } from './utils/collectionUtils.js'; +import { + evaluateAndCollectAdoptionStatusWithoutExceptions, + handleInternalError, +} from './utils/collectionUtils.js'; -const ERROR_MESSAGE = 'IPA exceptions must have a valid rule name and a reason.'; +const ERROR_MESSAGE_RULENAME_FORMAT = 'IPA exceptions must have a valid key with xgen-IPA- prefix.'; +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_PREFIX = 'xgen-IPA-'; // Note: This rule does not allow exceptions @@ -10,21 +14,44 @@ export default (input, _, { path, rule }) => { return evaluateAndCollectAdoptionStatusWithoutExceptions(errors, ruleName, path); }; -function isValidException(ruleName, reason) { - return ruleName.startsWith(RULE_NAME_PREFIX) && typeof reason === 'string' && reason !== ''; +function isRuleNameValid(ruleName) { + return ruleName.startsWith(RULE_NAME_PREFIX); +} + +function isReasonFormatValid(reason) { + if (reason === null || reason === undefined || typeof reason !== 'string' || reason === '') { + return false; + } + // Check if reason starts with uppercase letter + if (!/^[A-Z]/.test(reason)) { + return false; + } + + // Check if reason ends with a full stop + if (!reason.endsWith('.')) { + return false; + } + return true; } function checkViolationsAndReturnErrors(input, path, ruleName) { const errors = []; try { const exemptedRules = Object.keys(input); - exemptedRules.forEach((ruleName) => { - const reason = input[ruleName]; - if (!isValidException(ruleName, reason)) { + exemptedRules.forEach((key) => { + const reason = input[key]; + if (!isRuleNameValid(key)) { errors.push({ path: path.concat([ruleName]), - message: ERROR_MESSAGE, + message: ERROR_MESSAGE_RULENAME_FORMAT, }); + } else { + if (!isReasonFormatValid(reason)) { + errors.push({ + path: path.concat([ruleName]), + message: ERROR_MESSAGE_REASON_FORMAT, + }); + } } }); return errors; From b4e17311548e5de56ca6515b9681a3be1f32f826 Mon Sep 17 00:00:00 2001 From: Yeliz Henden Date: Fri, 22 Aug 2025 18:09:35 +0100 Subject: [PATCH 2/9] fix(ipa): exception reason formatting --- .../IPA005ExceptionExtensionFormat.test.js | 37 ++++++++++++++++++- .../IPA005ExceptionExtensionFormat.js | 14 +++---- 2 files changed, 41 insertions(+), 10 deletions(-) diff --git a/tools/spectral/ipa/__tests__/IPA005ExceptionExtensionFormat.test.js b/tools/spectral/ipa/__tests__/IPA005ExceptionExtensionFormat.test.js index 40efcf75f3..826a65161b 100644 --- a/tools/spectral/ipa/__tests__/IPA005ExceptionExtensionFormat.test.js +++ b/tools/spectral/ipa/__tests__/IPA005ExceptionExtensionFormat.test.js @@ -46,12 +46,27 @@ testRule('xgen-IPA-005-exception-extension-format', [ 'xgen-IPA-100-rule-name': {}, }, }, + '/path5': { + 'x-xgen-IPA-exception': { + 'xgen-IPA-1001-rule-name': {}, + }, + }, + '/path6': { + 'x-xgen-IPA-exception': { + 'xgen-IPA-1001-rule_name': {}, + }, + }, + '/path7': { + 'x-xgen-IPA-exception': { + 'xgen-IPA_100_rule-name': {}, + }, + }, }, }, errors: [ { code: 'xgen-IPA-005-exception-extension-format', - message: 'IPA exceptions must have a valid key with xgen-IPA- prefix.', + message: 'IPA exceptions must have a valid key following xgen-IPA-XXX-{rule-name} format.', path: ['paths', '/path1', 'x-xgen-IPA-exception'], severity: DiagnosticSeverity.Error, }, @@ -63,7 +78,7 @@ testRule('xgen-IPA-005-exception-extension-format', [ }, { code: 'xgen-IPA-005-exception-extension-format', - message: 'IPA exceptions must have a valid key with xgen-IPA- prefix.', + message: 'IPA exceptions must have a valid key following xgen-IPA-XXX-{rule-name} format.', path: ['paths', '/path3', 'x-xgen-IPA-exception'], severity: DiagnosticSeverity.Error, }, @@ -73,6 +88,24 @@ testRule('xgen-IPA-005-exception-extension-format', [ path: ['paths', '/path4', 'x-xgen-IPA-exception'], severity: DiagnosticSeverity.Error, }, + { + code: 'xgen-IPA-005-exception-extension-format', + message: 'IPA exceptions must have a valid key following xgen-IPA-XXX-{rule-name} format.', + path: ['paths', '/path5', 'x-xgen-IPA-exception'], + severity: DiagnosticSeverity.Error, + }, + { + code: 'xgen-IPA-005-exception-extension-format', + message: 'IPA exceptions must have a valid key following xgen-IPA-XXX-{rule-name} format.', + path: ['paths', '/path6', 'x-xgen-IPA-exception'], + severity: DiagnosticSeverity.Error, + }, + { + code: 'xgen-IPA-005-exception-extension-format', + message: 'IPA exceptions must have a valid key following xgen-IPA-XXX-{rule-name} format.', + path: ['paths', '/path7', 'x-xgen-IPA-exception'], + severity: DiagnosticSeverity.Error, + }, ], }, ]); diff --git a/tools/spectral/ipa/rulesets/functions/IPA005ExceptionExtensionFormat.js b/tools/spectral/ipa/rulesets/functions/IPA005ExceptionExtensionFormat.js index 00fbe6ce1b..fe087a73f3 100644 --- a/tools/spectral/ipa/rulesets/functions/IPA005ExceptionExtensionFormat.js +++ b/tools/spectral/ipa/rulesets/functions/IPA005ExceptionExtensionFormat.js @@ -1,11 +1,9 @@ -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 with xgen-IPA- prefix.'; -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_PREFIX = 'xgen-IPA-'; +const ERROR_MESSAGE_RULENAME_FORMAT = 'IPA exceptions must have a valid key following 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-]+$/; // Note: This rule does not allow exceptions export default (input, _, { path, rule }) => { @@ -15,7 +13,7 @@ export default (input, _, { path, rule }) => { }; function isRuleNameValid(ruleName) { - return ruleName.startsWith(RULE_NAME_PREFIX); + return RULE_NAME_PATTERN.test(ruleName); } function isReasonFormatValid(reason) { From 3b53a541b8e2894b06e16d90da6d272123907422 Mon Sep 17 00:00:00 2001 From: Yeliz Henden Date: Fri, 22 Aug 2025 18:10:43 +0100 Subject: [PATCH 3/9] doc fix --- tools/spectral/ipa/rulesets/IPA-005.yaml | 2 +- tools/spectral/ipa/rulesets/README.md | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/tools/spectral/ipa/rulesets/IPA-005.yaml b/tools/spectral/ipa/rulesets/IPA-005.yaml index fc36af00e6..5e9a955204 100644 --- a/tools/spectral/ipa/rulesets/IPA-005.yaml +++ b/tools/spectral/ipa/rulesets/IPA-005.yaml @@ -11,7 +11,7 @@ rules: ##### Implementation details Rule checks for the following conditions: - - Exception rule names must start with 'xgen-IPA-' prefix + - Exception rule names must follow 'xgen-IPA-XXX-{rule-name}' format. - 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 fc75253fb3..417c1fec58 100644 --- a/tools/spectral/ipa/rulesets/README.md +++ b/tools/spectral/ipa/rulesets/README.md @@ -19,8 +19,8 @@ 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 - - Each exception must include a non-empty reason as a string + - Exception rule names must follow 'xgen-IPA-XXX-{rule-name}' format. + - 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 From bc18f7ed8e2dafc1de0bf2480abd26d63cec8a94 Mon Sep 17 00:00:00 2001 From: Yeliz Henden Date: Fri, 22 Aug 2025 18:21:59 +0100 Subject: [PATCH 4/9] override --- tools/spectral/ipa/ipa-spectral.yaml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tools/spectral/ipa/ipa-spectral.yaml b/tools/spectral/ipa/ipa-spectral.yaml index a46dedf224..c0c3c3fc92 100644 --- a/tools/spectral/ipa/ipa-spectral.yaml +++ b/tools/spectral/ipa/ipa-spectral.yaml @@ -214,3 +214,7 @@ overrides: - '**#/paths/~1api~1atlas~1v2~1groups~1%7BgroupId%7D~1customDBRoles~1roles~1%7BroleName%7D' rules: xgen-IPA-102-collection-identifier-camelCase: 'off' + - files: + - '**' # Matches all files + rules: + xgen-IPA-005-exception-extension-format: 'off' From 79d1b1fe6c5efdd0ed9da78d84594a8b8ec258f8 Mon Sep 17 00:00:00 2001 From: Yeliz Henden Date: Fri, 22 Aug 2025 18:26:49 +0100 Subject: [PATCH 5/9] prettier fix --- tools/spectral/ipa/ipa-spectral.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/spectral/ipa/ipa-spectral.yaml b/tools/spectral/ipa/ipa-spectral.yaml index c0c3c3fc92..2bad9e8f9e 100644 --- a/tools/spectral/ipa/ipa-spectral.yaml +++ b/tools/spectral/ipa/ipa-spectral.yaml @@ -215,6 +215,6 @@ overrides: rules: xgen-IPA-102-collection-identifier-camelCase: 'off' - files: - - '**' # Matches all files + - '**' # Matches all files rules: xgen-IPA-005-exception-extension-format: 'off' From 2eb7fd37cd45eda483435b606ed61b327feb4e2b Mon Sep 17 00:00:00 2001 From: Yeliz Henden Date: Mon, 25 Aug 2025 15:06:30 +0100 Subject: [PATCH 6/9] logic fix --- .../IPA005ExceptionExtensionFormat.test.js | 50 +++++++++++++++++++ tools/spectral/ipa/rulesets/IPA-005.yaml | 2 +- .../IPA005ExceptionExtensionFormat.js | 7 ++- 3 files changed, 56 insertions(+), 3 deletions(-) diff --git a/tools/spectral/ipa/__tests__/IPA005ExceptionExtensionFormat.test.js b/tools/spectral/ipa/__tests__/IPA005ExceptionExtensionFormat.test.js index 826a65161b..2b9ce75d0b 100644 --- a/tools/spectral/ipa/__tests__/IPA005ExceptionExtensionFormat.test.js +++ b/tools/spectral/ipa/__tests__/IPA005ExceptionExtensionFormat.test.js @@ -11,10 +11,16 @@ testRule('xgen-IPA-005-exception-extension-format', [ 'xgen-IPA-100-rule-name': 'Exception.', }, }, + '/path-short': { + 'x-xgen-IPA-exception': { + 'xgen-IPA-100': 'Exception.', + }, + }, '/nested': { post: { 'x-xgen-IPA-exception': { 'xgen-IPA-100-rule-name': 'Exception.', + 'xgen-IPA-005': 'Short format exception.', }, }, }, @@ -61,6 +67,26 @@ testRule('xgen-IPA-005-exception-extension-format', [ 'xgen-IPA_100_rule-name': {}, }, }, + '/path8': { + 'x-xgen-IPA-exception': { + 'xgen-IPA-100-': 'Exception.', + }, + }, + '/path9': { + 'x-xgen-IPA-exception': { + 'xgen-IPA-5': 'Exception.', + }, + }, + '/path10': { + 'x-xgen-IPA-exception': { + 'xgen-IPA-100': 'exception without uppercase.', + }, + }, + '/path11': { + 'x-xgen-IPA-exception': { + 'xgen-IPA-100': 'Exception without period', + }, + }, }, }, errors: [ @@ -106,6 +132,30 @@ testRule('xgen-IPA-005-exception-extension-format', [ path: ['paths', '/path7', 'x-xgen-IPA-exception'], severity: DiagnosticSeverity.Error, }, + { + code: 'xgen-IPA-005-exception-extension-format', + message: 'IPA exceptions must have a valid key following xgen-IPA-XXX-{rule-name} format.', + path: ['paths', '/path8', 'x-xgen-IPA-exception'], + severity: DiagnosticSeverity.Error, + }, + { + code: 'xgen-IPA-005-exception-extension-format', + message: 'IPA exceptions must have a valid key following xgen-IPA-XXX-{rule-name} format.', + path: ['paths', '/path9', 'x-xgen-IPA-exception'], + severity: DiagnosticSeverity.Error, + }, + { + code: 'xgen-IPA-005-exception-extension-format', + message: 'IPA exceptions must have a non-empty reason that starts with uppercase and ends with a full stop.', + path: ['paths', '/path10', 'x-xgen-IPA-exception'], + severity: DiagnosticSeverity.Error, + }, + { + code: 'xgen-IPA-005-exception-extension-format', + message: 'IPA exceptions must have a non-empty reason that starts with uppercase and ends with a full stop.', + path: ['paths', '/path11', 'x-xgen-IPA-exception'], + severity: DiagnosticSeverity.Error, + }, ], }, ]); diff --git a/tools/spectral/ipa/rulesets/IPA-005.yaml b/tools/spectral/ipa/rulesets/IPA-005.yaml index 5e9a955204..fc36af00e6 100644 --- a/tools/spectral/ipa/rulesets/IPA-005.yaml +++ b/tools/spectral/ipa/rulesets/IPA-005.yaml @@ -11,7 +11,7 @@ rules: ##### Implementation details Rule checks for the following conditions: - - Exception rule names must follow 'xgen-IPA-XXX-{rule-name}' format. + - Exception rule names must start with 'xgen-IPA-' prefix - 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 fe087a73f3..1e33e76efc 100644 --- a/tools/spectral/ipa/rulesets/functions/IPA005ExceptionExtensionFormat.js +++ b/tools/spectral/ipa/rulesets/functions/IPA005ExceptionExtensionFormat.js @@ -1,9 +1,12 @@ -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-{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-z-]+)?$/; // Note: This rule does not allow exceptions export default (input, _, { path, rule }) => { From c93b6ebf1630f0966e53aac64b95942e37216842 Mon Sep 17 00:00:00 2001 From: Yeliz Henden Date: Mon, 25 Aug 2025 15:07:13 +0100 Subject: [PATCH 7/9] logic fix --- tools/spectral/ipa/rulesets/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/spectral/ipa/rulesets/README.md b/tools/spectral/ipa/rulesets/README.md index 417c1fec58..489e87a040 100644 --- a/tools/spectral/ipa/rulesets/README.md +++ b/tools/spectral/ipa/rulesets/README.md @@ -19,7 +19,7 @@ IPA exception extensions must follow the correct format. ##### Implementation details Rule checks for the following conditions: - - Exception rule names must follow 'xgen-IPA-XXX-{rule-name}' format. + - Exception rule names must start with 'xgen-IPA-' prefix - 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 From de6039e9cc57cd5ce15d5a7a526afa33d91f0d38 Mon Sep 17 00:00:00 2001 From: Yeliz Henden Date: Mon, 25 Aug 2025 15:11:06 +0100 Subject: [PATCH 8/9] logic fix --- .../IPA005ExceptionExtensionFormat.test.js | 14 +++++++------- tools/spectral/ipa/rulesets/IPA-005.yaml | 1 + .../functions/IPA005ExceptionExtensionFormat.js | 2 +- 3 files changed, 9 insertions(+), 8 deletions(-) diff --git a/tools/spectral/ipa/__tests__/IPA005ExceptionExtensionFormat.test.js b/tools/spectral/ipa/__tests__/IPA005ExceptionExtensionFormat.test.js index 2b9ce75d0b..fda9121389 100644 --- a/tools/spectral/ipa/__tests__/IPA005ExceptionExtensionFormat.test.js +++ b/tools/spectral/ipa/__tests__/IPA005ExceptionExtensionFormat.test.js @@ -92,7 +92,7 @@ testRule('xgen-IPA-005-exception-extension-format', [ errors: [ { code: 'xgen-IPA-005-exception-extension-format', - message: 'IPA exceptions must have a valid key following xgen-IPA-XXX-{rule-name} format.', + message: 'IPA exceptions must have a valid key following xgen-IPA-XXX or xgen-IPA-XXX-{rule-name} format.', path: ['paths', '/path1', 'x-xgen-IPA-exception'], severity: DiagnosticSeverity.Error, }, @@ -104,7 +104,7 @@ testRule('xgen-IPA-005-exception-extension-format', [ }, { code: 'xgen-IPA-005-exception-extension-format', - message: 'IPA exceptions must have a valid key following xgen-IPA-XXX-{rule-name} format.', + message: 'IPA exceptions must have a valid key following xgen-IPA-XXX or xgen-IPA-XXX-{rule-name} format.', path: ['paths', '/path3', 'x-xgen-IPA-exception'], severity: DiagnosticSeverity.Error, }, @@ -116,31 +116,31 @@ testRule('xgen-IPA-005-exception-extension-format', [ }, { code: 'xgen-IPA-005-exception-extension-format', - message: 'IPA exceptions must have a valid key following xgen-IPA-XXX-{rule-name} format.', + message: 'IPA exceptions must have a valid key following xgen-IPA-XXX or xgen-IPA-XXX-{rule-name} format.', path: ['paths', '/path5', 'x-xgen-IPA-exception'], severity: DiagnosticSeverity.Error, }, { code: 'xgen-IPA-005-exception-extension-format', - message: 'IPA exceptions must have a valid key following xgen-IPA-XXX-{rule-name} format.', + message: 'IPA exceptions must have a valid key following xgen-IPA-XXX or xgen-IPA-XXX-{rule-name} format.', path: ['paths', '/path6', 'x-xgen-IPA-exception'], severity: DiagnosticSeverity.Error, }, { code: 'xgen-IPA-005-exception-extension-format', - message: 'IPA exceptions must have a valid key following xgen-IPA-XXX-{rule-name} format.', + message: 'IPA exceptions must have a valid key following xgen-IPA-XXX or xgen-IPA-XXX-{rule-name} format.', path: ['paths', '/path7', 'x-xgen-IPA-exception'], severity: DiagnosticSeverity.Error, }, { code: 'xgen-IPA-005-exception-extension-format', - message: 'IPA exceptions must have a valid key following xgen-IPA-XXX-{rule-name} format.', + message: 'IPA exceptions must have a valid key following xgen-IPA-XXX or xgen-IPA-XXX-{rule-name} format.', path: ['paths', '/path8', 'x-xgen-IPA-exception'], severity: DiagnosticSeverity.Error, }, { code: 'xgen-IPA-005-exception-extension-format', - message: 'IPA exceptions must have a valid key following xgen-IPA-XXX-{rule-name} format.', + message: 'IPA exceptions must have a valid key following xgen-IPA-XXX or xgen-IPA-XXX-{rule-name} format.', path: ['paths', '/path9', 'x-xgen-IPA-exception'], severity: DiagnosticSeverity.Error, }, diff --git a/tools/spectral/ipa/rulesets/IPA-005.yaml b/tools/spectral/ipa/rulesets/IPA-005.yaml index fc36af00e6..dbe38f99e4 100644 --- a/tools/spectral/ipa/rulesets/IPA-005.yaml +++ b/tools/spectral/ipa/rulesets/IPA-005.yaml @@ -12,6 +12,7 @@ rules: ##### Implementation details Rule checks for the following conditions: - Exception rule names must start with 'xgen-IPA-' prefix + - Exception rule names can be either short format (xgen-IPA-XXX) or full format (xgen-IPA-XXX-rule-name) - 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 1e33e76efc..f8bedfb285 100644 --- a/tools/spectral/ipa/rulesets/functions/IPA005ExceptionExtensionFormat.js +++ b/tools/spectral/ipa/rulesets/functions/IPA005ExceptionExtensionFormat.js @@ -3,7 +3,7 @@ import { handleInternalError, } from './utils/collectionUtils.js'; -const ERROR_MESSAGE_RULENAME_FORMAT = 'IPA exceptions must have a valid key following xgen-IPA-XXX-{rule-name} format.'; +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-]+)?$/; From fe0298b09737032731a4f8a31bfe952dde5f69f6 Mon Sep 17 00:00:00 2001 From: Yeliz Henden Date: Mon, 25 Aug 2025 15:13:08 +0100 Subject: [PATCH 9/9] prettier fix --- tools/spectral/ipa/rulesets/README.md | 1 + .../rulesets/functions/IPA005ExceptionExtensionFormat.js | 8 +++----- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/tools/spectral/ipa/rulesets/README.md b/tools/spectral/ipa/rulesets/README.md index 489e87a040..eea19fa3dc 100644 --- a/tools/spectral/ipa/rulesets/README.md +++ b/tools/spectral/ipa/rulesets/README.md @@ -20,6 +20,7 @@ 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 can be either short format (xgen-IPA-XXX) or full format (xgen-IPA-XXX-rule-name) - 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 f8bedfb285..0d320ca630 100644 --- a/tools/spectral/ipa/rulesets/functions/IPA005ExceptionExtensionFormat.js +++ b/tools/spectral/ipa/rulesets/functions/IPA005ExceptionExtensionFormat.js @@ -1,9 +1,7 @@ -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_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-]+)?$/;