Skip to content

Commit ec63243

Browse files
CLOUDP-303615: Address comments
1 parent 2ee94dc commit ec63243

File tree

2 files changed

+26
-21
lines changed

2 files changed

+26
-21
lines changed

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

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ testRule('xgen-IPA-113-singleton-must-not-have-id', [
66
name: 'valid resources',
77
document: {
88
paths: {
9-
'/standard': {
9+
'/resource': {
1010
post: {},
1111
get: {
1212
responses: {
@@ -26,7 +26,7 @@ testRule('xgen-IPA-113-singleton-must-not-have-id', [
2626
},
2727
},
2828
},
29-
'/standard/{exampleId}': {
29+
'/resource/{exampleId}': {
3030
get: {
3131
responses: {
3232
200: {
@@ -47,7 +47,7 @@ testRule('xgen-IPA-113-singleton-must-not-have-id', [
4747
patch: {},
4848
delete: {},
4949
},
50-
'/standard/{exampleId}/singleton1': {
50+
'/resource/{exampleId}/singleton1': {
5151
get: {
5252
responses: {
5353
200: {
@@ -65,7 +65,7 @@ testRule('xgen-IPA-113-singleton-must-not-have-id', [
6565
},
6666
},
6767
},
68-
'/standard/{exampleId}/singleton2': {
68+
'/resource/{exampleId}/singleton2': {
6969
get: {
7070
responses: {
7171
200: {
@@ -92,7 +92,7 @@ testRule('xgen-IPA-113-singleton-must-not-have-id', [
9292
name: 'invalid resources',
9393
document: {
9494
paths: {
95-
'/standard/{exampleId}/singleton1': {
95+
'/resource/{exampleId}/singleton1': {
9696
get: {
9797
responses: {
9898
200: {
@@ -111,7 +111,7 @@ testRule('xgen-IPA-113-singleton-must-not-have-id', [
111111
},
112112
},
113113
},
114-
'/standard/{exampleId}/singleton2': {
114+
'/resource/{exampleId}/singleton2': {
115115
get: {
116116
responses: {
117117
200: {
@@ -130,7 +130,7 @@ testRule('xgen-IPA-113-singleton-must-not-have-id', [
130130
},
131131
},
132132
},
133-
'/standard/{exampleId}/singleton3': {
133+
'/resource/{exampleId}/singleton3': {
134134
get: {
135135
responses: {
136136
200: {
@@ -164,19 +164,19 @@ testRule('xgen-IPA-113-singleton-must-not-have-id', [
164164
{
165165
code: 'xgen-IPA-113-singleton-must-not-have-id',
166166
message: 'Singleton resources must not have a user-provided or system-generated ID. http://go/ipa/113',
167-
path: ['paths', '/standard/{exampleId}/singleton1'],
167+
path: ['paths', '/resource/{exampleId}/singleton1'],
168168
severity: DiagnosticSeverity.Warning,
169169
},
170170
{
171171
code: 'xgen-IPA-113-singleton-must-not-have-id',
172172
message: 'Singleton resources must not have a user-provided or system-generated ID. http://go/ipa/113',
173-
path: ['paths', '/standard/{exampleId}/singleton2'],
173+
path: ['paths', '/resource/{exampleId}/singleton2'],
174174
severity: DiagnosticSeverity.Warning,
175175
},
176176
{
177177
code: 'xgen-IPA-113-singleton-must-not-have-id',
178178
message: 'Singleton resources must not have a user-provided or system-generated ID. http://go/ipa/113',
179-
path: ['paths', '/standard/{exampleId}/singleton3'],
179+
path: ['paths', '/resource/{exampleId}/singleton3'],
180180
severity: DiagnosticSeverity.Warning,
181181
},
182182
],
@@ -185,7 +185,7 @@ testRule('xgen-IPA-113-singleton-must-not-have-id', [
185185
name: 'invalid resources with exceptions',
186186
document: {
187187
paths: {
188-
'/singleton1': {
188+
'/resource/{exampleId}/singleton1': {
189189
'x-xgen-IPA-exception': {
190190
'xgen-IPA-113-singleton-must-not-have-id': 'reason',
191191
},

tools/spectral/ipa/__tests__/utils/resourceEvaluation.test.js

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,23 +5,28 @@ import {
55
isStandardResource,
66
} from '../../rulesets/functions/utils/resourceEvaluation';
77

8-
const standardResourcePaths = ['/standard', '/standard/{exampleId}'];
8+
const standardResourcePaths = ['/resource', '/resource/{exampleId}'];
99

10-
const nestedStandardResourcePaths = ['/standard/{exampleId}/nested', '/standard/{exampleId}/nested/{exampleId}'];
10+
const nestedStandardResourcePaths = ['/resource/{exampleId}/nested', '/resource/{exampleId}/nested/{exampleId}'];
1111

12-
const standardResourceWithCustomPaths = ['/customStandard', '/customStandard/{exampleId}', '/customStandard:method'];
12+
const standardResourceWithCustomPaths = [
13+
'/customStandard',
14+
'/customStandard/{exampleId}',
15+
'/customStandard/{id}:method',
16+
'/customStandard:method',
17+
];
1318

1419
const standardResourceMissingSubPath = ['/standardMissingSub'];
1520

1621
const standardResourceMissingSubPathInvalidFormat = ['/standard/nestedStandardMissingSub'];
1722

1823
const standardResourcePathsInvalidFormat = ['/resource1/resource2', '/resource1/resource2/{exampleId}'];
1924

20-
const singletonResourcePaths = ['/standard/{exampleId}/singleton'];
25+
const singletonResourcePaths = ['/resource/{exampleId}/singleton'];
2126

2227
const singletonResourceWithCustomPaths = [
23-
'/standard/{exampleId}/customSingleton',
24-
'/standard/{exampleId}/customSingleton:method',
28+
'/resource/{exampleId}/customSingleton',
29+
'/resource/{exampleId}/customSingleton:method',
2530
];
2631

2732
const allPaths = standardResourcePaths.concat(
@@ -39,12 +44,12 @@ describe('tools/spectral/ipa/rulesets/functions/utils/resourceEvaluation.js', ()
3944
const testCases = [
4045
{
4146
description: 'standard resource',
42-
resourceCollectionPath: '/standard',
47+
resourceCollectionPath: '/resource',
4348
expectedPaths: standardResourcePaths,
4449
},
4550
{
4651
description: 'nested standard resource',
47-
resourceCollectionPath: '/standard/{exampleId}/nested',
52+
resourceCollectionPath: '/resource/{exampleId}/nested',
4853
expectedPaths: nestedStandardResourcePaths,
4954
},
5055
{
@@ -69,12 +74,12 @@ describe('tools/spectral/ipa/rulesets/functions/utils/resourceEvaluation.js', ()
6974
},
7075
{
7176
description: 'singleton resource',
72-
resourceCollectionPath: '/standard/{exampleId}/singleton',
77+
resourceCollectionPath: '/resource/{exampleId}/singleton',
7378
expectedPaths: singletonResourcePaths,
7479
},
7580
{
7681
description: 'singleton resource with custom methods',
77-
resourceCollectionPath: '/standard/{exampleId}/customSingleton',
82+
resourceCollectionPath: '/resource/{exampleId}/customSingleton',
7883
expectedPaths: singletonResourceWithCustomPaths,
7984
},
8085
];

0 commit comments

Comments
 (0)