11import testRule from './__helpers__/testRule' ;
2-
3- // TODO: add tests for xgen-custom-method extension - CLOUDP-306294
4- // TOOD: enable tests for invalid methods (after rules are upgraded to warning) - CLOUDP-329722
2+ import { DiagnosticSeverity } from '@stoplight/types' ;
53
64testRule ( 'xgen-IPA-104-valid-operation-id' , [
75 {
@@ -17,19 +15,33 @@ testRule('xgen-IPA-104-valid-operation-id', [
1715 } ,
1816 errors : [ ] ,
1917 } ,
20- // This test will be enable when the xgen-IPA-104-valid-operation-id is set to warning severity - CLOUDP-329722
21- /* {
22- name: 'invalid methods',
18+ {
19+ name : 'invalid methods with short opIDs' ,
2320 document : {
2421 paths : {
25- '/api/atlas/v2/groups/{groupId}/accessList/{entryValue}/status ': {
22+ '/api/atlas/v2/groups/{groupId}/accessList/{entryValue}' : {
2623 get : {
27- operationId: 'getProjectIpAccessListStatus ',
24+ operationId : 'getProjectIpList ' ,
2825 } ,
2926 } ,
30- '/api/atlas/v2/groups/{groupId}/dataFederation/{tenantName}/limits/{limitName}': {
27+ } ,
28+ } ,
29+ errors : [
30+ {
31+ code : 'xgen-IPA-104-valid-operation-id' ,
32+ message : "Invalid OperationID. Found 'getProjectIpList', expected 'getGroupAccessList'. " ,
33+ path : [ 'paths' , '/api/atlas/v2/groups/{groupId}/accessList/{entryValue}' , 'get' , 'operationId' ] ,
34+ severity : DiagnosticSeverity . Warning ,
35+ } ,
36+ ] ,
37+ } ,
38+ {
39+ name : 'invalid methods with long opIDs' ,
40+ document : {
41+ paths : {
42+ '/api/atlas/v2/groups/{groupId}/alerts/{alertId}/alertConfigs' : {
3143 get : {
32- operationId: 'returnFederatedDatabaseQueryLimit ',
44+ operationId : 'listAlertConfigurationsByAlertId ' ,
3345 } ,
3446 } ,
3547 } ,
@@ -38,19 +50,85 @@ testRule('xgen-IPA-104-valid-operation-id', [
3850 {
3951 code : 'xgen-IPA-104-valid-operation-id' ,
4052 message :
41- ' Invalid OperationID. ' ,
42- path: ['paths', '/api/atlas/v2/groups/{groupId}/accessList/{entryValue}/status ', 'get'],
53+ " Invalid OperationID. Found 'listAlertConfigurationsByAlertId', expected 'getGroupAlertAlertConfigs'. " ,
54+ path : [ 'paths' , '/api/atlas/v2/groups/{groupId}/alerts/{alertId}/alertConfigs ' , 'get' , 'operationId '] ,
4355 severity : DiagnosticSeverity . Warning ,
4456 } ,
4557 {
4658 code : 'xgen-IPA-104-valid-operation-id' ,
4759 message :
48- 'Invalid OperationID. ' ,
49- path: ['paths', '/api/atlas/v2/groups/{groupId}/dataFederation/{tenantName}/limits/{limitName} ', 'get'],
60+ "The Operation ID is longer than 4 words. Please add an 'x-xgen-operation-id-override' extension to the operation with a shorter operation ID. " ,
61+ path : [ 'paths' , '/api/atlas/v2/groups/{groupId}/alerts/{alertId}/alertConfigs ' , 'get' , 'operationId '] ,
5062 severity : DiagnosticSeverity . Warning ,
5163 } ,
5264 ] ,
53- }, */
65+ } ,
66+ {
67+ name : 'valid methods with valid overrides' ,
68+ document : {
69+ paths : {
70+ '/api/atlas/v2/federationSettings/{federationSettingsId}/connectedOrgConfigs/{orgId}/roleMappings/{id}' : {
71+ get : {
72+ operationId : 'getFederationSettingConnectedOrgConfigRoleMapping' ,
73+ 'x-xgen-operation-id-override' : 'getRoleMapping' ,
74+ } ,
75+ } ,
76+ } ,
77+ } ,
78+ errors : [ ] ,
79+ } ,
80+ {
81+ name : 'valid methods with invalid overrides' ,
82+ document : {
83+ paths : {
84+ '/api/atlas/v2/federationSettings/{federationSettingsId}/connectedOrgConfigs/{orgId}/roleMappings/{id}' : {
85+ get : {
86+ operationId : 'getFederationSettingConnectedOrgConfigRoleMapping' ,
87+ 'x-xgen-operation-id-override' : 'getGroupRoleConfig' ,
88+ } ,
89+ } ,
90+ } ,
91+ } ,
92+ errors : [
93+ {
94+ code : 'xgen-IPA-104-valid-operation-id' ,
95+ message :
96+ "The operation ID override must only contain nouns from the operation ID 'getFederationSettingConnectedOrgConfigRoleMapping'. " ,
97+ path : [
98+ 'paths' ,
99+ '/api/atlas/v2/federationSettings/{federationSettingsId}/connectedOrgConfigs/{orgId}/roleMappings/{id}' ,
100+ 'get' ,
101+ 'x-xgen-operation-id-override' ,
102+ ] ,
103+ severity : DiagnosticSeverity . Warning ,
104+ } ,
105+ {
106+ code : 'xgen-IPA-104-valid-operation-id' ,
107+ message : "The operation ID override must end with the noun 'Mapping'. " ,
108+ path : [
109+ 'paths' ,
110+ '/api/atlas/v2/federationSettings/{federationSettingsId}/connectedOrgConfigs/{orgId}/roleMappings/{id}' ,
111+ 'get' ,
112+ 'x-xgen-operation-id-override' ,
113+ ] ,
114+ severity : DiagnosticSeverity . Warning ,
115+ } ,
116+ ] ,
117+ } ,
118+ {
119+ name : 'valid method with verb overrides' ,
120+ document : {
121+ paths : {
122+ '/api/atlas/v2/groups/{groupId}/streams/{tenantName}' : {
123+ get : {
124+ operationId : 'getGroupStreamWorkspace' ,
125+ 'x-xgen-method-verb-override' : { verb : 'getWorkspace' , customMethod : false } ,
126+ } ,
127+ } ,
128+ } ,
129+ } ,
130+ errors : [ ] ,
131+ } ,
54132 {
55133 name : 'invalid methods with exceptions' ,
56134 document : {
0 commit comments