Skip to content

Commit 8c45fba

Browse files
CLOUDP-304053: IPA-106:Create - The resource must be the request body (exclude readOnly:true and writeOnly:true)
1 parent 7449c54 commit 8c45fba

File tree

6 files changed

+278
-182
lines changed

6 files changed

+278
-182
lines changed

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

Lines changed: 25 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,16 @@ const componentSchemas = {
66
SchemaOne: {
77
type: 'string',
88
},
9-
SchemaTwo: {
9+
SchemaTwoRequest: {
1010
type: 'object',
1111
properties: {
1212
name: {
1313
type: 'string',
14-
readOnly: true,
14+
writeOnly: true,
1515
},
16+
otherThing: {
17+
type: 'string',
18+
}
1619
},
1720
},
1821
SchemaThree: {
@@ -29,13 +32,16 @@ const componentSchemas = {
2932
},
3033
},
3134
},
32-
SchemaFour: {
35+
SchemaTwoResponse: {
3336
type: 'object',
3437
properties: {
3538
name: {
3639
type: 'string',
37-
writeOnly: true,
40+
readOnly: true,
3841
},
42+
otherThing: {
43+
type: 'string',
44+
}
3945
},
4046
},
4147
SchemaCircularOne: {
@@ -132,12 +138,12 @@ testRule('xgen-IPA-106-create-method-request-body-is-get-method-response', [
132138
content: {
133139
'application/vnd.atlas.2023-01-01+json': {
134140
schema: {
135-
$ref: '#/components/schemas/SchemaTwo',
141+
$ref: '#/components/schemas/SchemaTwoRequest',
136142
},
137143
},
138144
'application/vnd.atlas.2024-01-01+json': {
139145
schema: {
140-
$ref: '#/components/schemas/SchemaTwo',
146+
$ref: '#/components/schemas/SchemaTwoRequest',
141147
},
142148
},
143149
},
@@ -151,7 +157,12 @@ testRule('xgen-IPA-106-create-method-request-body-is-get-method-response', [
151157
content: {
152158
'application/vnd.atlas.2023-01-01+json': {
153159
schema: {
154-
$ref: '#/components/schemas/SchemaFour',
160+
$ref: '#/components/schemas/SchemaTwoResponse',
161+
},
162+
},
163+
'application/vnd.atlas.2024-01-01+json': {
164+
schema: {
165+
$ref: '#/components/schemas/SchemaTwoResponse',
155166
},
156167
},
157168
},
@@ -244,7 +255,7 @@ testRule('xgen-IPA-106-create-method-request-body-is-get-method-response', [
244255
content: {
245256
'application/vnd.atlas.2023-01-01+json': {
246257
schema: {
247-
$ref: '#/components/schemas/SchemaTwo',
258+
$ref: '#/components/schemas/SchemaTwoRequest',
248259
},
249260
},
250261
},
@@ -258,12 +269,12 @@ testRule('xgen-IPA-106-create-method-request-body-is-get-method-response', [
258269
content: {
259270
'application/vnd.atlas.2023-01-01+json': {
260271
schema: {
261-
$ref: '#/components/schemas/SchemaTwo',
272+
$ref: '#/components/schemas/SchemaTwoResponse',
262273
},
263274
},
264275
'application/vnd.atlas.2024-01-01+json': {
265276
schema: {
266-
$ref: '#/components/schemas/SchemaTwo',
277+
$ref: '#/components/schemas/SchemaTwoResponse',
267278
},
268279
},
269280
},
@@ -511,14 +522,6 @@ testRule('xgen-IPA-106-create-method-request-body-is-get-method-response', [
511522
'xgen-IPA-106-create-method-request-body-is-get-method-response': 'reason',
512523
},
513524
},
514-
'application/vnd.atlas.2024-01-01+json': {
515-
schema: {
516-
$ref: '#/components/schemas/SchemaOne',
517-
},
518-
'x-xgen-IPA-exception': {
519-
'xgen-IPA-106-create-method-request-body-is-get-method-response': 'reason',
520-
},
521-
},
522525
},
523526
},
524527
},
@@ -530,7 +533,7 @@ testRule('xgen-IPA-106-create-method-request-body-is-get-method-response', [
530533
content: {
531534
'application/vnd.atlas.2023-01-01+json': {
532535
schema: {
533-
$ref: '#/components/schemas/SchemaTwo',
536+
$ref: '#/components/schemas/SchemaThree',
534537
},
535538
},
536539
},
@@ -544,15 +547,15 @@ testRule('xgen-IPA-106-create-method-request-body-is-get-method-response', [
544547
content: {
545548
'application/vnd.atlas.2023-01-01+json': {
546549
schema: {
547-
$ref: '#/components/schemas/SchemaTwo',
550+
$ref: '#/components/schemas/SchemaTwoRequest',
548551
},
549552
'x-xgen-IPA-exception': {
550553
'xgen-IPA-106-create-method-request-body-is-get-method-response': 'reason',
551554
},
552555
},
553556
'application/vnd.atlas.2024-01-01+json': {
554557
schema: {
555-
$ref: '#/components/schemas/SchemaTwo',
558+
$ref: '#/components/schemas/SchemaTwoRequest',
556559
},
557560
'x-xgen-IPA-exception': {
558561
'xgen-IPA-106-create-method-request-body-is-get-method-response': 'reason',
@@ -569,43 +572,7 @@ testRule('xgen-IPA-106-create-method-request-body-is-get-method-response', [
569572
content: {
570573
'application/vnd.atlas.2023-01-01+json': {
571574
schema: {
572-
$ref: '#/components/schemas/SchemaThree',
573-
},
574-
},
575-
},
576-
},
577-
},
578-
},
579-
},
580-
'/resourceThree': {
581-
post: {
582-
requestBody: {
583-
content: {
584-
'application/vnd.atlas.2023-01-01+json': {
585-
schema: {
586-
$ref: '#/components/schemas/SchemaOne',
587-
},
588-
'x-xgen-IPA-exception': {
589-
'xgen-IPA-106-create-method-request-body-is-get-method-response': 'reason',
590-
},
591-
},
592-
'application/vnd.atlas.2024-01-01+json': {
593-
schema: {
594-
$ref: '#/components/schemas/SchemaThree',
595-
},
596-
},
597-
},
598-
},
599-
},
600-
},
601-
'/resourceThree/{id}': {
602-
get: {
603-
responses: {
604-
200: {
605-
content: {
606-
'application/vnd.atlas.2023-01-01+json': {
607-
schema: {
608-
$ref: '#/components/schemas/SchemaThree',
575+
$ref: '#/components/schemas/SchemaTwoResponse',
609576
},
610577
},
611578
},

0 commit comments

Comments
 (0)