Skip to content

Commit b418110

Browse files
test commit
1 parent 00cec89 commit b418110

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

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

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,12 +47,10 @@ function checkViolationsAndReturnErrors(apiResponseObject, oas, path, errorCode)
4747
const schemaName = getSchemaNameFromRef(apiResponseObject.$ref);
4848
const responseSchema = resolveObject(oas, ['components', 'responses', schemaName]);
4949
content = responseSchema.content;
50-
console.log(responseSchema);
5150
} else {
5251
return [{ path, message: `${errorCode} response must define content with ApiError schema reference.` }];
5352
}
5453

55-
/*
5654
for (const [mediaType, mediaTypeObj] of Object.entries(content)) {
5755
if (!mediaType.endsWith('json')) {
5856
continue;
@@ -77,7 +75,7 @@ function checkViolationsAndReturnErrors(apiResponseObject, oas, path, errorCode)
7775
message: `${errorCode} response must reference ApiError schema.`,
7876
});
7977
}
80-
}*/
78+
}
8179
return errors;
8280
} catch (e) {
8381
handleInternalError(RULE_NAME, path, e);

tools/spectral/ipa/rulesets/functions/utils/componentUtils.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,11 @@ export function isPathParam(str) {
4242
* console.log(result); // Output: { fieldName: { type: 'string' } }
4343
*/
4444
export function resolveObject(oas, objectPath) {
45+
if (!objectPath || !Array.isArray(objectPath)) {
46+
console.log(objectPath);
47+
return undefined;
48+
}
49+
4550
return objectPath.reduce((current, key) => {
4651
return current && current[key] ? current[key] : undefined;
4752
}, oas);

0 commit comments

Comments
 (0)