Skip to content

Commit 9db89a3

Browse files
committed
fix: IPA-108
1 parent 834a776 commit 9db89a3

File tree

2 files changed

+68
-19
lines changed

2 files changed

+68
-19
lines changed

tools/spectral/ipa/rulesets/IPA-108.yaml

Lines changed: 33 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,31 +3,60 @@
33

44
rules:
55
xgen-IPA-108-delete-response-should-be-empty:
6-
description: Delete method response should not have schema reference to object.
6+
description: |
7+
Delete method response should not have schema reference to object.
8+
9+
##### Implementation details
10+
Rule checks for the following conditions:
11+
- Applies to 204 responses in DELETE methods
12+
- Verifies that the response does not contain a schema property
13+
- Fails if any content type in the response has a defined schema as reference
714
message: '{{error}} https://mdb.link/mongodb-atlas-openapi-validation#xgen-IPA-108-delete-response-should-be-empty'
815
severity: warn
916
given: $.paths[*].delete.responses[204]
1017
then:
1118
function: IPA108DeleteMethodResponseShouldNotHaveSchema
1219

1320
xgen-IPA-108-delete-method-return-204-response:
14-
description: DELETE method must return 204 No Content.
21+
description: |
22+
DELETE method must return 204 No Content.
23+
24+
##### Implementation details
25+
Rule checks for the following conditions:
26+
- Applies to all DELETE methods
27+
- Verifies that the method includes a 204 response code
28+
- Ensures no other 2xx response codes are defined
29+
- Fails if the 204 status code is missing or if other 2xx responses exist
1530
message: '{{error}} https://mdb.link/mongodb-atlas-openapi-validation#xgen-IPA-108-delete-method-return-204-response'
1631
severity: warn
1732
given: $.paths[*].delete
1833
then:
1934
function: IPA108DeleteMethod204Response
2035

2136
xgen-IPA-108-delete-include-404-response:
22-
description: DELETE method must include 404 response and return it when resource not found.
37+
description: |
38+
DELETE method must include 404 response and return it when resource not found.
39+
40+
##### Implementation details
41+
Rule checks for the following conditions:
42+
- Applies to all DELETE methods
43+
- Verifies that the method includes a 404 response code
44+
- Fails if the 404 status code is missing from the responses
2345
message: '{{error}} https://mdb.link/mongodb-atlas-openapi-validation#xgen-IPA-108-delete-include-404-response'
2446
severity: warn
2547
given: $.paths[*].delete
2648
then:
2749
function: IPA108DeleteMethod404Response
2850

2951
xgen-IPA-108-delete-request-no-body:
30-
description: DELETE method must not have request body.
52+
description: |
53+
DELETE method must not have request body.
54+
55+
##### Implementation details
56+
Rule checks for the following conditions:
57+
- Applies to all DELETE methods
58+
- Verifies that the operation object does not contain a requestBody property
59+
- Fails if any requestBody is defined for the DELETE method
3160
message: '{{error}} https://mdb.link/mongodb-atlas-openapi-validation#xgen-IPA-108-delete-request-no-body'
3261
severity: warn
3362
given: $.paths[*].delete

tools/spectral/ipa/rulesets/README.md

Lines changed: 35 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -318,30 +318,50 @@ Validation checks the PATCH method for single resource paths and [singleton reso
318318

319319
Rule is based on [http://go/ipa/IPA-108](http://go/ipa/IPA-108).
320320

321-
#### xgen-IPA-108-custom-method-must-be-GET-or-POST
321+
#### xgen-IPA-108-delete-response-should-be-empty
322322

323-
![error](https://img.shields.io/badge/error-red)
324-
The HTTP method for custom methods must be GET or POST.
323+
![warn](https://img.shields.io/badge/warning-yellow)
324+
Delete method response should not have schema reference to object.
325325

326326
##### Implementation details
327327
Rule checks for the following conditions:
328-
- Applies only to paths containing custom method identifiers (with colon format)
329-
- Verifies the HTTP methods used are either GET or POST
330-
- Fails if any other HTTP methods are used (PUT, DELETE, PATCH, etc.)
331-
- Fails if multiple valid methods are defined for the same custom method endpoint
328+
- Applies to 204 responses in DELETE methods
329+
- Verifies that the response does not contain a schema property
330+
- Fails if any content type in the response has a defined schema as reference
332331

333-
#### xgen-IPA-108-custom-method-must-use-camel-case
332+
#### xgen-IPA-108-delete-method-return-204-response
334333

335-
![error](https://img.shields.io/badge/error-red)
336-
The custom method must use camelCase format.
334+
![warn](https://img.shields.io/badge/warning-yellow)
335+
DELETE method must return 204 No Content.
337336

338337
##### Implementation details
339338
Rule checks for the following conditions:
340-
- Applies only to paths containing custom method identifiers (with colon format)
341-
- Extracts the method name portion following the colon
342-
- Verifies the method name is not empty or blank
343-
- Validates that the method name uses proper camelCase formatting
344-
- Fails if the method name contains invalid casing (such as snake_case, PascalCase, etc.)
339+
- Applies to all DELETE methods
340+
- Verifies that the method includes a 204 response code
341+
- Ensures no other 2xx response codes are defined
342+
- Fails if the 204 status code is missing or if other 2xx responses exist
343+
344+
#### xgen-IPA-108-delete-include-404-response
345+
346+
![warn](https://img.shields.io/badge/warning-yellow)
347+
DELETE method must include 404 response and return it when resource not found.
348+
349+
##### Implementation details
350+
Rule checks for the following conditions:
351+
- Applies to all DELETE methods
352+
- Verifies that the method includes a 404 response code
353+
- Fails if the 404 status code is missing from the responses
354+
355+
#### xgen-IPA-108-delete-request-no-body
356+
357+
![warn](https://img.shields.io/badge/warning-yellow)
358+
DELETE method must not have request body.
359+
360+
##### Implementation details
361+
Rule checks for the following conditions:
362+
- Applies to all DELETE methods
363+
- Verifies that the operation object does not contain a requestBody property
364+
- Fails if any requestBody is defined for the DELETE method
345365

346366

347367

0 commit comments

Comments
 (0)