Skip to content

Commit 7aa9c17

Browse files
author
Sophia Marie Terry
committed
IPA 106 tests for overrides
1 parent 87da16f commit 7aa9c17

File tree

1 file changed

+78
-0
lines changed

1 file changed

+78
-0
lines changed

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

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,84 @@ testRule('xgen-IPA-106-valid-operation-id', [
7474
},
7575
],
7676
},
77+
{
78+
name: 'valid methods with valid overrides',
79+
document: {
80+
paths: {
81+
'/api/atlas/v2/federationSettings/{federationSettingsId}/connectedOrgConfigs/{orgId}/roleMappings': {
82+
post: {
83+
operationId: 'createFederationSettingConnectedOrgConfigRoleMapping',
84+
'x-xgen-operation-id-override': 'createRoleMapping',
85+
},
86+
},
87+
},
88+
},
89+
errors: [],
90+
},
91+
{
92+
name: 'valid methods with invalid overrides',
93+
document: {
94+
paths: {
95+
'/api/atlas/v2/federationSettings/{federationSettingsId}/connectedOrgConfigs/{orgId}/roleMappings': {
96+
post: {
97+
operationId: 'createFederationSettingConnectedOrgConfigRoleMapping',
98+
'x-xgen-operation-id-override': 'createSettingIDConfigTest',
99+
},
100+
},
101+
},
102+
},
103+
errors: [
104+
{
105+
code: 'xgen-IPA-106-valid-operation-id',
106+
message: 'The operation ID override is longer than 4 words. Please shorten it. ',
107+
path: [
108+
'paths',
109+
'/api/atlas/v2/federationSettings/{federationSettingsId}/connectedOrgConfigs/{orgId}/roleMappings',
110+
'post',
111+
'x-xgen-operation-id-override',
112+
],
113+
severity: DiagnosticSeverity.Warning,
114+
},
115+
{
116+
code: 'xgen-IPA-106-valid-operation-id',
117+
message:
118+
"The operation ID override must only contain nouns from the operation ID 'createFederationSettingConnectedOrgConfigRoleMapping'. ",
119+
path: [
120+
'paths',
121+
'/api/atlas/v2/federationSettings/{federationSettingsId}/connectedOrgConfigs/{orgId}/roleMappings',
122+
'post',
123+
'x-xgen-operation-id-override',
124+
],
125+
severity: DiagnosticSeverity.Warning,
126+
},
127+
{
128+
code: 'xgen-IPA-106-valid-operation-id',
129+
message: "The operation ID override must end with the noun 'Mapping'. ",
130+
path: [
131+
'paths',
132+
'/api/atlas/v2/federationSettings/{federationSettingsId}/connectedOrgConfigs/{orgId}/roleMappings',
133+
'post',
134+
'x-xgen-operation-id-override',
135+
],
136+
severity: DiagnosticSeverity.Warning,
137+
},
138+
],
139+
},
140+
{
141+
name: 'valid method with verb overrides',
142+
document: {
143+
paths: {
144+
'/api/atlas/v2/groups/{groupId}/serverless': {
145+
post: {
146+
operationId: 'createGroupServerlessInstance',
147+
'x-xgen-method-verb-override': { verb: 'createInstance', customMethod: false },
148+
'x-xgen-operation-id-override': 'createServerlessInstance',
149+
},
150+
},
151+
},
152+
},
153+
errors: [],
154+
},
77155
{
78156
name: 'invalid methods with exceptions',
79157
document: {

0 commit comments

Comments
 (0)