Skip to content

Commit fe4c9ba

Browse files
authored
fix(ipa): Add ignore list for nouns in OperationID Validation (#901)
1 parent ec9a70b commit fe4c9ba

21 files changed

+183
-17
lines changed

tools/spectral/ipa/__tests__/IPA104ValidOperationID.test.js

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,4 +145,18 @@ testRule('xgen-IPA-104-valid-operation-id', [
145145
},
146146
errors: [],
147147
},
148+
{
149+
name: 'valid method that needs ignoreList',
150+
document: {
151+
paths: {
152+
'/api/atlas/v2/groups/{groupId}/clusters/{clusterName}/fts/indexes/{indexId} ': {
153+
get: {
154+
operationId: 'getGroupClusterFtsIndex',
155+
'x-xgen-operation-id-override': 'getClusterFtsIndex',
156+
},
157+
},
158+
},
159+
},
160+
errors: [],
161+
},
148162
]);

tools/spectral/ipa/__tests__/IPA105ValidOperationID.test.js

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,4 +136,18 @@ testRule('xgen-IPA-105-valid-operation-id', [
136136
},
137137
errors: [],
138138
},
139+
{
140+
name: 'valid method that needs ignoreList',
141+
document: {
142+
paths: {
143+
'/api/atlas/v2/groups/{groupId}/hosts/{processId}/fts/metrics': {
144+
get: {
145+
operationId: 'listGroupHostFtsMetrics',
146+
'x-xgen-operation-id-override': 'listHostFtsMetrics',
147+
},
148+
},
149+
},
150+
},
151+
errors: [],
152+
},
139153
]);

tools/spectral/ipa/__tests__/IPA106ValidOperationID.test.js

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,4 +168,18 @@ testRule('xgen-IPA-106-valid-operation-id', [
168168
},
169169
errors: [],
170170
},
171+
{
172+
name: 'valid method that needs ignoreList',
173+
document: {
174+
paths: {
175+
'/api/atlas/v2/groups/{groupId}/clusters/{clusterName}/fts/indexes': {
176+
post: {
177+
operationId: 'createGroupClusterFtsIndex',
178+
'x-xgen-operation-id-override': 'createClusterFtsIndex',
179+
},
180+
},
181+
},
182+
},
183+
errors: [],
184+
},
171185
]);

tools/spectral/ipa/__tests__/IPA107ValidOperationID.test.js

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,4 +162,18 @@ testRule('xgen-IPA-107-valid-operation-id', [
162162
},
163163
errors: [],
164164
},
165+
{
166+
name: 'valid method that needs ignoreList',
167+
document: {
168+
paths: {
169+
'/api/atlas/v2/groups/{groupId}/clusters/{clusterName}/fts/indexes/{indexId}': {
170+
put: {
171+
operationId: 'updateGroupClusterFtsIndex',
172+
'x-xgen-operation-id-override': 'updateClusterFtsIndex',
173+
},
174+
},
175+
},
176+
},
177+
errors: [],
178+
},
165179
]);

tools/spectral/ipa/__tests__/IPA108ValidOperationID.test.js

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,4 +167,18 @@ testRule('xgen-IPA-108-valid-operation-id', [
167167
},
168168
errors: [],
169169
},
170+
{
171+
name: 'valid method that needs ignoreList',
172+
document: {
173+
paths: {
174+
'/api/atlas/v2/groups/{groupId}/clusters/{clusterName}/fts/indexes/{indexId}': {
175+
delete: {
176+
operationId: 'deleteGroupClusterFtsIndex',
177+
'x-xgen-operation-id-override': 'deleteClusterFtsIndex',
178+
},
179+
},
180+
},
181+
},
182+
errors: [],
183+
},
170184
]);

tools/spectral/ipa/__tests__/IPA109ValidOperationID.test.js

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,4 +137,18 @@ testRule('xgen-IPA-109-valid-operation-id', [
137137
},
138138
errors: [],
139139
},
140+
{
141+
name: 'valid method that needs ignoreList',
142+
document: {
143+
paths: {
144+
'/api/atlas/v2/groups/{groupId}/clusters/{clusterName}/fts/indexes/{indexId}:test': {
145+
delete: {
146+
operationId: 'testGroupClusterFtsIndex',
147+
'x-xgen-operation-id-override': 'testClusterFtsIndex',
148+
},
149+
},
150+
},
151+
},
152+
errors: [],
153+
},
140154
]);

tools/spectral/ipa/rulesets/IPA-104.yaml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,10 +108,17 @@ rules:
108108
Rule checks for the following conditions:
109109
- Applies only to GET methods on single resources or singleton resources
110110
- Confirms that the existing OperationId is compliant with generated IPA Compliant OperationId
111+
112+
##### Configuration
113+
This rule includes two configuration options:
114+
- `methodName`: The verb to be used in the OperationIds
115+
- `ignorePluralizationList`: Words that are allowed to maintain their assumed plurality (e.g., "Fts")
111116
message: '{{error}} https://mdb.link/mongodb-atlas-openapi-validation#xgen-IPA-104-valid-operation-id'
112117
severity: warn
113118
given: '#GetOperationObject'
114119
then:
115120
function: 'IPA104ValidOperationID'
116121
functionOptions:
117122
methodName: 'get'
123+
ignorePluralizationList:
124+
- 'Fts'

tools/spectral/ipa/rulesets/IPA-105.yaml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,10 +88,17 @@ rules:
8888
- Applies only to GET methods on resource collection paths
8989
- Ignores singleton resources
9090
- Confirms that the existing OperationId is compliant with generated IPA Compliant OperationId
91+
92+
##### Configuration
93+
This rule includes two configuration options:
94+
- `methodName`: The verb to be used in the OperationIds
95+
- `ignorePluralizationList`: Words that are allowed to maintain their assumed plurality (e.g., "Fts")
9196
message: '{{error}} https://mdb.link/mongodb-atlas-openapi-validation#xgen-IPA-105-valid-operation-id'
9297
severity: warn
9398
given: '#GetOperationObject'
9499
then:
95100
function: 'IPA105ValidOperationID'
96101
functionOptions:
97102
methodName: 'list'
103+
ignorePluralizationList:
104+
- 'Fts'

tools/spectral/ipa/rulesets/IPA-106.yaml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,10 +122,17 @@ rules:
122122
Rule checks for the following conditions:
123123
- Applies only to POST methods that are not [custom methods](https://mongodb.github.io/ipa/109)
124124
- Confirms that the existing OperationId is compliant with generated IPA Compliant OperationId
125+
126+
##### Configuration
127+
This rule includes two configuration options:
128+
- `methodName`: The verb to be used in the OperationIds
129+
- `ignorePluralizationList`: Words that are allowed to maintain their assumed plurality (e.g., "Fts")
125130
message: '{{error}} https://mdb.link/mongodb-atlas-openapi-validation#xgen-IPA-106-valid-operation-id'
126131
severity: warn
127132
given: '#CreateOperationObject'
128133
then:
129134
function: 'IPA106ValidOperationID'
130135
functionOptions:
131136
methodName: 'create'
137+
ignorePluralizationList:
138+
- 'Fts'

tools/spectral/ipa/rulesets/IPA-107.yaml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,10 +123,17 @@ rules:
123123
Rule checks for the following conditions:
124124
- Applies only to PUT/PATCH methods that are not [custom methods](https://mongodb.github.io/ipa/109)
125125
- Confirms that the existing OperationId is compliant with generated IPA Compliant OperationId
126+
127+
##### Configuration
128+
This rule includes two configuration options:
129+
- `methodName`: The verb to be used in the OperationIds
130+
- `ignorePluralizationList`: Words that are allowed to maintain their assumed plurality (e.g., "Fts")
126131
message: '{{error}} https://mdb.link/mongodb-atlas-openapi-validation#xgen-IPA-107-valid-operation-id'
127132
severity: warn
128133
given: '#UpdateOperationObject'
129134
then:
130135
function: 'IPA107ValidOperationID'
131136
functionOptions:
132137
methodName: 'update'
138+
ignorePluralizationList:
139+
- 'Fts'

0 commit comments

Comments
 (0)