Skip to content

Commit d6af94f

Browse files
fix
1 parent f8f0928 commit d6af94f

File tree

2 files changed

+8
-10
lines changed

2 files changed

+8
-10
lines changed

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

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ rules:
1919
description: 'The HTTP response status code for GET operations should be 200 OK. http://go/ipa/104'
2020
message: '{{error}} http://go/ipa/104'
2121
severity: warn
22-
given: '$.paths.*'
22+
given: '$.paths[*].get'
2323
then:
24-
field: '@key'
2524
function: 'getResponseCodeShouldBe200OK'

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

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,19 @@
11
import { hasException } from './utils/exceptions.js';
22
import { collectAdoption, collectAndReturnViolation, collectException } from './utils/collectionUtils.js';
3-
import { resolveObject } from './utils/componentUtils.js';
43

54
const RULE_NAME = 'xgen-IPA-104-GET-response-code-should-be-200-OK';
65
const ERROR_MESSAGE = 'The HTTP response status code for GET operations should be 200 OK.';
76

8-
export default (input, _, { path, documentInventory }) => {
9-
const oas = documentInventory.resolved;
10-
const getOperation = resolveObject(oas, path);
11-
if (hasException(getOperation, RULE_NAME)) {
12-
collectException(getOperation, RULE_NAME, path);
7+
export default (input, _, { path }) => {
8+
console.log(input);
9+
10+
if (hasException(input, RULE_NAME)) {
11+
collectException(input, RULE_NAME, path);
1312
return;
1413
}
1514

16-
if (getOperation.responses) {
17-
const responses = getOperation.responses;
15+
if (input['responses']) {
16+
const responses = input['responses'];
1817
if (!responses['200']) {
1918
return collectAndReturnViolation(path, RULE_NAME, ERROR_MESSAGE);
2019
}

0 commit comments

Comments
 (0)