Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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.',
},
},
},
Expand Down
3 changes: 2 additions & 1 deletion tools/spectral/ipa/rulesets/IPA-005.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down
3 changes: 2 additions & 1 deletion tools/spectral/ipa/rulesets/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 }) => {
Expand Down
Loading