Skip to content

Commit dec7a89

Browse files
committed
fix: spec for IPA 108
1 parent b1351c4 commit dec7a89

File tree

2 files changed

+5
-18
lines changed

2 files changed

+5
-18
lines changed

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

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -26,16 +26,7 @@ rules:
2626
then:
2727
function: deleteMethod404Response
2828

29-
xgen-IPA-108-delete-request-no-body:
30-
description: DELETE method must not have request body
31-
message: '{{error}} http://go/ipa/108'
32-
severity: warn
33-
given: $.paths[*].delete
34-
then:
35-
function: deleteMethodNoRequestBody
36-
3729
functions:
3830
- deleteMethodResponseShouldNotHaveSchema
3931
- deleteMethod204Response
40-
- deleteMethodNoRequestBody
4132
- deleteMethod404Response

tools/spectral/ipa/rulesets/functions/deleteMethod404Response.js

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -12,18 +12,14 @@ const ERROR_MESSAGE = 'DELETE method should include 404 status code for not foun
1212
* @param {object} context - The context object containing the path
1313
*/
1414
export default (input, _, { path }) => {
15-
const deleteOp = input;
16-
if (!deleteOp) return;
17-
18-
if (hasException(deleteOp, RULE_NAME)) {
19-
collectException(deleteOp, RULE_NAME, path);
15+
const responses = input.responses;
16+
if (hasException(input, RULE_NAME)) {
17+
collectException(input, RULE_NAME, path);
2018
return;
2119
}
2220

23-
const responses = deleteOp.responses || {};
24-
if (!responses['404']) {
21+
if (!responses || !responses['404']) {
2522
return collectAndReturnViolation(path, RULE_NAME, ERROR_MESSAGE);
2623
}
27-
28-
collectAdoption(path, RULE_NAME);
24+
return collectAdoption(path, RULE_NAME);
2925
};

0 commit comments

Comments
 (0)