Skip to content

Commit 2ee94dc

Browse files
CLOUDP-303615: IPA - Update check if resource is singleton/standard
1 parent 7101319 commit 2ee94dc

9 files changed

+253
-106
lines changed

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

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,6 @@ testRule('xgen-IPA-104-resource-has-GET', [
4343
'/custom:method': {
4444
post: {},
4545
},
46-
'/singleton': {
47-
get: {},
48-
},
4946
},
5047
},
5148
errors: [],
@@ -87,8 +84,8 @@ testRule('xgen-IPA-104-resource-has-GET', [
8784
'/custom:method': {
8885
post: {},
8986
},
90-
'/singleton': {
91-
patch: {},
87+
'/standardWithoutSubResource': {
88+
get: {},
9289
},
9390
},
9491
},
@@ -120,7 +117,7 @@ testRule('xgen-IPA-104-resource-has-GET', [
120117
{
121118
code: 'xgen-IPA-104-resource-has-GET',
122119
message: 'APIs must provide a get method for resources. http://go/ipa/104',
123-
path: ['paths', '/singleton'],
120+
path: ['paths', '/standardWithoutSubResource'],
124121
severity: DiagnosticSeverity.Warning,
125122
},
126123
],

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

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ testRule('xgen-IPA-104-get-method-returns-single-resource', [
7373
},
7474
},
7575
},
76-
'/singleton': {
76+
'/resource/{id}/singleton': {
7777
get: {
7878
responses: {
7979
200: {
@@ -127,7 +127,7 @@ testRule('xgen-IPA-104-get-method-returns-single-resource', [
127127
},
128128
},
129129
},
130-
'/arraySingleton': {
130+
'/resource/{id}/arraySingleton': {
131131
get: {
132132
responses: {
133133
200: {
@@ -142,7 +142,7 @@ testRule('xgen-IPA-104-get-method-returns-single-resource', [
142142
},
143143
},
144144
},
145-
'/paginatedSingleton': {
145+
'/resource/{id}/paginatedSingleton': {
146146
get: {
147147
responses: {
148148
200: {
@@ -197,7 +197,7 @@ testRule('xgen-IPA-104-get-method-returns-single-resource', [
197197
'Get methods should return data for a single resource. This method returns an array or a paginated response. http://go/ipa/104',
198198
path: [
199199
'paths',
200-
'/arraySingleton',
200+
'/resource/{id}/arraySingleton',
201201
'get',
202202
'responses',
203203
'200',
@@ -212,7 +212,7 @@ testRule('xgen-IPA-104-get-method-returns-single-resource', [
212212
'Get methods should return data for a single resource. This method returns an array or a paginated response. http://go/ipa/104',
213213
path: [
214214
'paths',
215-
'/paginatedSingleton',
215+
'/resource/{id}/paginatedSingleton',
216216
'get',
217217
'responses',
218218
'200',
@@ -245,7 +245,7 @@ testRule('xgen-IPA-104-get-method-returns-single-resource', [
245245
},
246246
},
247247
},
248-
'/paginatedSingleton': {
248+
'/resource/{id}/paginatedSingleton': {
249249
get: {
250250
responses: {
251251
200: {

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

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ testRule('xgen-IPA-113-singleton-must-not-have-id', [
4747
patch: {},
4848
delete: {},
4949
},
50-
'/singleton1': {
50+
'/standard/{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-
'/singleton2': {
68+
'/standard/{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-
'/singleton1': {
95+
'/standard/{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-
'/singleton2': {
114+
'/standard/{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-
'/singleton3': {
133+
'/standard/{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', '/singleton1'],
167+
path: ['paths', '/standard/{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', '/singleton2'],
173+
path: ['paths', '/standard/{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', '/singleton3'],
179+
path: ['paths', '/standard/{exampleId}/singleton3'],
180180
severity: DiagnosticSeverity.Warning,
181181
},
182182
],

0 commit comments

Comments
 (0)