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 @@ -12,6 +12,8 @@ testRule('xgen-IPA-112-avoid-project-field-names', [
group: { type: 'string' },
groupId: { type: 'string' },
projection: { type: 'number' },
gcpProjectId: { type: 'string' },
somethingWithGcpProjectId: { type: 'string' },
},
},
},
Expand Down
3 changes: 3 additions & 0 deletions tools/spectral/ipa/rulesets/IPA-112.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ rules:
Rule checks for the following conditions:
- Searches through all schemas in the API definition
- Identifies property names that match "project" (case-insensitive)
- Ignores fields where prohibited words appear with specified words (e.g., "gcpProjectId")
- Reports any instances where these field names are used
- Suggests using "group", "groups", or "groupId" as alternatives
message: '{{error}} https://mdb.link/mongodb-atlas-openapi-validation#xgen-IPA-112-avoid-project-field-names'
Expand All @@ -26,3 +27,5 @@ rules:
alternative: ['group']
- name: 'projects'
alternative: ['groups']
ignore:
- 'gcp'
1 change: 1 addition & 0 deletions tools/spectral/ipa/rulesets/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -460,6 +460,7 @@ Schema field names should avoid using "project", "projects", or "projectId".
Rule checks for the following conditions:
- Searches through all schemas in the API definition
- Identifies property names that match "project" (case-insensitive)
- Ignores fields where prohibited words appear with specified words (e.g., "gcpProjectId")
- Reports any instances where these field names are used
- Suggests using "group", "groups", or "groupId" as alternatives

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,11 @@ export default (input, options, { path, documentInventory }) => {
const oas = documentInventory.resolved;
const property = resolveObject(oas, path);

const ignoreList = options?.ignore || [];
if (ignoreList.some((ignoreTerm) => input.toLowerCase().includes(ignoreTerm))) {
return;
}

if (hasException(property, RULE_NAME)) {
collectException(property, RULE_NAME, path);
return;
Expand Down
Loading