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
14 changes: 14 additions & 0 deletions tools/spectral/ipa/__tests__/IPA104ValidOperationID.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -145,4 +145,18 @@ testRule('xgen-IPA-104-valid-operation-id', [
},
errors: [],
},
{
name: 'valid method that needs ignoreList',
document: {
paths: {
'/api/atlas/v2/groups/{groupId}/clusters/{clusterName}/fts/indexes/{indexId} ': {
get: {
operationId: 'getGroupClusterFtsIndex',
'x-xgen-operation-id-override': 'getClusterFtsIndex',
},
},
},
},
errors: [],
},
]);
14 changes: 14 additions & 0 deletions tools/spectral/ipa/__tests__/IPA105ValidOperationID.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -136,4 +136,18 @@ testRule('xgen-IPA-105-valid-operation-id', [
},
errors: [],
},
{
name: 'valid method that needs ignoreList',
document: {
paths: {
'/api/atlas/v2/groups/{groupId}/hosts/{processId}/fts/metrics': {
get: {
operationId: 'listGroupHostFtsMetrics',
'x-xgen-operation-id-override': 'listHostFtsMetrics',
},
},
},
},
errors: [],
},
]);
14 changes: 14 additions & 0 deletions tools/spectral/ipa/__tests__/IPA106ValidOperationID.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -168,4 +168,18 @@ testRule('xgen-IPA-106-valid-operation-id', [
},
errors: [],
},
{
name: 'valid method that needs ignoreList',
document: {
paths: {
'/api/atlas/v2/groups/{groupId}/clusters/{clusterName}/fts/indexes': {
post: {
operationId: 'createGroupClusterFtsIndex',
'x-xgen-operation-id-override': 'createClusterFtsIndex',
},
},
},
},
errors: [],
},
]);
14 changes: 14 additions & 0 deletions tools/spectral/ipa/__tests__/IPA107ValidOperationID.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -162,4 +162,18 @@ testRule('xgen-IPA-107-valid-operation-id', [
},
errors: [],
},
{
name: 'valid method that needs ignoreList',
document: {
paths: {
'/api/atlas/v2/groups/{groupId}/clusters/{clusterName}/fts/indexes/{indexId}': {
put: {
operationId: 'updateGroupClusterFtsIndex',
'x-xgen-operation-id-override': 'updateClusterFtsIndex',
},
},
},
},
errors: [],
},
]);
14 changes: 14 additions & 0 deletions tools/spectral/ipa/__tests__/IPA108ValidOperationID.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -167,4 +167,18 @@ testRule('xgen-IPA-108-valid-operation-id', [
},
errors: [],
},
{
name: 'valid method that needs ignoreList',
document: {
paths: {
'/api/atlas/v2/groups/{groupId}/clusters/{clusterName}/fts/indexes/{indexId}': {
delete: {
operationId: 'deleteGroupClusterFtsIndex',
'x-xgen-operation-id-override': 'deleteClusterFtsIndex',
},
},
},
},
errors: [],
},
]);
14 changes: 14 additions & 0 deletions tools/spectral/ipa/__tests__/IPA109ValidOperationID.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -137,4 +137,18 @@ testRule('xgen-IPA-109-valid-operation-id', [
},
errors: [],
},
{
name: 'valid method that needs ignoreList',
document: {
paths: {
'/api/atlas/v2/groups/{groupId}/clusters/{clusterName}/fts/indexes/{indexId}:test': {
delete: {
operationId: 'testGroupClusterFtsIndex',
'x-xgen-operation-id-override': 'testClusterFtsIndex',
},
},
},
},
errors: [],
},
]);
7 changes: 7 additions & 0 deletions tools/spectral/ipa/rulesets/IPA-104.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -108,10 +108,17 @@ rules:
Rule checks for the following conditions:
- Applies only to GET methods on single resources or singleton resources
- Confirms that the existing OperationId is compliant with generated IPA Compliant OperationId

##### Configuration
This rule includes two configuration options:
- `methodName`: The verb to be used in the OperationIds
- `ignorePluralizationList`: Words that are allowed to maintain their assumed plurality (e.g., "Fts")
message: '{{error}} https://mdb.link/mongodb-atlas-openapi-validation#xgen-IPA-104-valid-operation-id'
severity: warn
given: '#GetOperationObject'
then:
function: 'IPA104ValidOperationID'
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you add to the rule description an explanation of the ignore list option and what it is used for? Similar to

##### Configuration
This rule includes two configuration options:
- `ignoreList`: Words that are allowed to maintain their specific casing (e.g., "API", "AWS", "DNS")
- `grammaticalWords`: Common words that can remain lowercase in titles (e.g., "and", "or", "the")

functionOptions:
methodName: 'get'
ignorePluralizationList:
- 'Fts'
7 changes: 7 additions & 0 deletions tools/spectral/ipa/rulesets/IPA-105.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -88,10 +88,17 @@ rules:
- Applies only to GET methods on resource collection paths
- Ignores singleton resources
- Confirms that the existing OperationId is compliant with generated IPA Compliant OperationId

##### Configuration
This rule includes two configuration options:
- `methodName`: The verb to be used in the OperationIds
- `ignorePluralizationList`: Words that are allowed to maintain their assumed plurality (e.g., "Fts")
message: '{{error}} https://mdb.link/mongodb-atlas-openapi-validation#xgen-IPA-105-valid-operation-id'
severity: warn
given: '#GetOperationObject'
then:
function: 'IPA105ValidOperationID'
functionOptions:
methodName: 'list'
ignorePluralizationList:
- 'Fts'
7 changes: 7 additions & 0 deletions tools/spectral/ipa/rulesets/IPA-106.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -122,10 +122,17 @@ rules:
Rule checks for the following conditions:
- Applies only to POST methods that are not [custom methods](https://mongodb.github.io/ipa/109)
- Confirms that the existing OperationId is compliant with generated IPA Compliant OperationId

##### Configuration
This rule includes two configuration options:
- `methodName`: The verb to be used in the OperationIds
- `ignorePluralizationList`: Words that are allowed to maintain their assumed plurality (e.g., "Fts")
message: '{{error}} https://mdb.link/mongodb-atlas-openapi-validation#xgen-IPA-106-valid-operation-id'
severity: warn
given: '#CreateOperationObject'
then:
function: 'IPA106ValidOperationID'
functionOptions:
methodName: 'create'
ignorePluralizationList:
- 'Fts'
7 changes: 7 additions & 0 deletions tools/spectral/ipa/rulesets/IPA-107.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -123,10 +123,17 @@ rules:
Rule checks for the following conditions:
- Applies only to PUT/PATCH methods that are not [custom methods](https://mongodb.github.io/ipa/109)
- Confirms that the existing OperationId is compliant with generated IPA Compliant OperationId

##### Configuration
This rule includes two configuration options:
- `methodName`: The verb to be used in the OperationIds
- `ignorePluralizationList`: Words that are allowed to maintain their assumed plurality (e.g., "Fts")
message: '{{error}} https://mdb.link/mongodb-atlas-openapi-validation#xgen-IPA-107-valid-operation-id'
severity: warn
given: '#UpdateOperationObject'
then:
function: 'IPA107ValidOperationID'
functionOptions:
methodName: 'update'
ignorePluralizationList:
- 'Fts'
6 changes: 6 additions & 0 deletions tools/spectral/ipa/rulesets/IPA-108.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -64,13 +64,19 @@ rules:
Rule checks for the following conditions:
- Applies only to DELETE methods that are not [custom methods](https://mongodb.github.io/ipa/109)
- Confirms that the existing OperationId is compliant with generated IPA Compliant OperationId
##### Configuration
This rule includes two configuration options:
- `methodName`: The verb to be used in the OperationIds
- `ignorePluralizationList`: Words that are allowed to maintain their assumed plurality (e.g., "Fts")
message: '{{error}} https://mdb.link/mongodb-atlas-openapi-validation#xgen-IPA-108-valid-operation-id'
severity: warn
given: '#DeleteOperationObject'
then:
function: 'IPA108ValidOperationID'
functionOptions:
methodName: 'delete'
ignorePluralizationList:
- 'Fts'

functions:
- IPA108DeleteMethodResponseShouldNotHaveSchema
Expand Down
7 changes: 7 additions & 0 deletions tools/spectral/ipa/rulesets/IPA-109.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,15 @@ rules:
Rule checks for the following conditions:
- Applies only to paths containing custom method identifiers (with colon format)
- Confirms that the existing OperationId is compliant with generated IPA Compliant OperationId

##### Configuration
This rule includes one configuration options:
- `ignorePluralizationList`: Words that are allowed to maintain their assumed plurality (e.g., "Fts")
message: '{{error}} https://mdb.link/mongodb-atlas-openapi-validation#xgen-IPA-109-valid-operation-id'
severity: warn
given: '$.paths[*][*]'
then:
function: 'IPA109ValidOperationID'
functionOptions:
ignorePluralizationList:
- 'Fts'
28 changes: 28 additions & 0 deletions tools/spectral/ipa/rulesets/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,11 @@ Rule checks for the following conditions:
- Applies only to GET methods on single resources or singleton resources
- Confirms that the existing OperationId is compliant with generated IPA Compliant OperationId

##### Configuration
This rule includes two configuration options:
- `methodName`: The verb to be used in the OperationIds
- `ignorePluralizationList`: Words that are allowed to maintain their assumed plurality (e.g., "Fts")



### IPA-105
Expand Down Expand Up @@ -220,6 +225,11 @@ Rule checks for the following conditions:
- Ignores singleton resources
- Confirms that the existing OperationId is compliant with generated IPA Compliant OperationId

##### Configuration
This rule includes two configuration options:
- `methodName`: The verb to be used in the OperationIds
- `ignorePluralizationList`: Words that are allowed to maintain their assumed plurality (e.g., "Fts")



### IPA-106
Expand Down Expand Up @@ -311,6 +321,11 @@ Rule checks for the following conditions:
- Applies only to POST methods that are not [custom methods](https://mongodb.github.io/ipa/109)
- Confirms that the existing OperationId is compliant with generated IPA Compliant OperationId

##### Configuration
This rule includes two configuration options:
- `methodName`: The verb to be used in the OperationIds
- `ignorePluralizationList`: Words that are allowed to maintain their assumed plurality (e.g., "Fts")



### IPA-107
Expand Down Expand Up @@ -394,6 +409,11 @@ Rule checks for the following conditions:
- Applies only to PUT/PATCH methods that are not [custom methods](https://mongodb.github.io/ipa/109)
- Confirms that the existing OperationId is compliant with generated IPA Compliant OperationId

##### Configuration
This rule includes two configuration options:
- `methodName`: The verb to be used in the OperationIds
- `ignorePluralizationList`: Words that are allowed to maintain their assumed plurality (e.g., "Fts")



### IPA-108
Expand Down Expand Up @@ -448,6 +468,10 @@ The noun(s) in the Operation ID should be the collection identifiers from the re
Rule checks for the following conditions:
- Applies only to DELETE methods that are not [custom methods](https://mongodb.github.io/ipa/109)
- Confirms that the existing OperationId is compliant with generated IPA Compliant OperationId
##### Configuration
This rule includes two configuration options:
- `methodName`: The verb to be used in the OperationIds
- `ignorePluralizationList`: Words that are allowed to maintain their assumed plurality (e.g., "Fts")



Expand Down Expand Up @@ -509,6 +533,10 @@ Rule checks for the following conditions:
- Applies only to paths containing custom method identifiers (with colon format)
- Confirms that the existing OperationId is compliant with generated IPA Compliant OperationId

##### Configuration
This rule includes one configuration options:
- `ignorePluralizationList`: Words that are allowed to maintain their assumed plurality (e.g., "Fts")



### IPA-110
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { validateOperationIdAndReturnErrors } from './utils/validations/validate

const RULE_NAME = 'xgen-IPA-104-valid-operation-id';

export default (input, { methodName }, { path, documentInventory }) => {
export default (input, { methodName, ignorePluralizationList }, { path, documentInventory }) => {
const resourcePath = path[1];
const oas = documentInventory.resolved;
const resourcePaths = getResourcePathItems(resourcePath, oas.paths);
Expand All @@ -23,7 +23,7 @@ export default (input, { methodName }, { path, documentInventory }) => {
if (hasMethodVerbOverride(input, methodName)) {
methodName = input[VERB_OVERRIDE_EXTENSION].verb;
}
const errors = validateOperationIdAndReturnErrors(methodName, resourcePath, input, path);
const errors = validateOperationIdAndReturnErrors(methodName, resourcePath, input, path, ignorePluralizationList);

return evaluateAndCollectAdoptionStatus(errors, RULE_NAME, input, path);
} catch (e) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { validateOperationIdAndReturnErrors } from './utils/validations/validate

const RULE_NAME = 'xgen-IPA-105-valid-operation-id';

export default (input, { methodName }, { path, documentInventory }) => {
export default (input, { methodName, ignorePluralizationList }, { path, documentInventory }) => {
const resourcePath = path[1];
const oas = documentInventory.resolved;
const resourcePaths = getResourcePathItems(resourcePath, oas.paths);
Expand All @@ -24,7 +24,7 @@ export default (input, { methodName }, { path, documentInventory }) => {
}

try {
const errors = validateOperationIdAndReturnErrors(methodName, resourcePath, input, path);
const errors = validateOperationIdAndReturnErrors(methodName, resourcePath, input, path, ignorePluralizationList);
return evaluateAndCollectAdoptionStatus(errors, RULE_NAME, input, path);
} catch (e) {
return handleInternalError(RULE_NAME, path, e);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { validateOperationIdAndReturnErrors } from './utils/validations/validate

const RULE_NAME = 'xgen-IPA-106-valid-operation-id';

export default (input, { methodName }, { path }) => {
export default (input, { methodName, ignorePluralizationList }, { path }) => {
const resourcePath = path[1];

if (hasCustomMethodOverride(input) || isCustomMethodIdentifier(resourcePath)) {
Expand All @@ -17,7 +17,7 @@ export default (input, { methodName }, { path }) => {
}

try {
const errors = validateOperationIdAndReturnErrors(methodName, resourcePath, input, path);
const errors = validateOperationIdAndReturnErrors(methodName, resourcePath, input, path, ignorePluralizationList);
return evaluateAndCollectAdoptionStatus(errors, RULE_NAME, input, path);
} catch (e) {
return handleInternalError(RULE_NAME, path, e);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { validateOperationIdAndReturnErrors } from './utils/validations/validate

const RULE_NAME = 'xgen-IPA-107-valid-operation-id';

export default (input, { methodName }, { path }) => {
export default (input, { methodName, ignorePluralizationList }, { path }) => {
const resourcePath = path[1];

if (isCustomMethodIdentifier(resourcePath) || hasCustomMethodOverride(input)) {
Expand All @@ -17,7 +17,7 @@ export default (input, { methodName }, { path }) => {
}

try {
const errors = validateOperationIdAndReturnErrors(methodName, resourcePath, input, path);
const errors = validateOperationIdAndReturnErrors(methodName, resourcePath, input, path, ignorePluralizationList);
return evaluateAndCollectAdoptionStatus(errors, RULE_NAME, input, path);
} catch (e) {
return handleInternalError(RULE_NAME, path, e);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { validateOperationIdAndReturnErrors } from './utils/validations/validate

const RULE_NAME = 'xgen-IPA-108-valid-operation-id';

export default (input, { methodName }, { path }) => {
export default (input, { methodName, ignorePluralizationList }, { path }) => {
const resourcePath = path[1];

if (isCustomMethodIdentifier(resourcePath) || hasCustomMethodOverride(input)) {
Expand All @@ -17,7 +17,7 @@ export default (input, { methodName }, { path }) => {
}

try {
const errors = validateOperationIdAndReturnErrors(methodName, resourcePath, input, path);
const errors = validateOperationIdAndReturnErrors(methodName, resourcePath, input, path, ignorePluralizationList);
return evaluateAndCollectAdoptionStatus(errors, RULE_NAME, input, path);
} catch (e) {
return handleInternalError(RULE_NAME, path, e);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { validateOperationIdAndReturnErrors } from './utils/validations/validate

const RULE_NAME = 'xgen-IPA-109-valid-operation-id';

export default (input, _, { path }) => {
export default (input, { ignorePluralizationList }, { path }) => {
const resourcePath = path[1];

if (!isCustomMethodIdentifier(resourcePath) && !hasCustomMethodOverride(input)) {
Expand All @@ -28,7 +28,7 @@ export default (input, _, { path }) => {
return;
}

const errors = validateOperationIdAndReturnErrors(methodName, endpointUrl, input, path);
const errors = validateOperationIdAndReturnErrors(methodName, endpointUrl, input, path, ignorePluralizationList);
return evaluateAndCollectAdoptionStatus(errors, RULE_NAME, input, path);
} catch (e) {
return handleInternalError(RULE_NAME, path, e);
Expand Down
Loading
Loading