Skip to content

Commit 3120015

Browse files
test commit
1 parent b418110 commit 3120015

File tree

2 files changed

+3
-5
lines changed

2 files changed

+3
-5
lines changed

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,9 @@ function checkViolationsAndReturnErrors(apiResponseObject, oas, path, errorCode)
4646
} else if (apiResponseObject.$ref) {
4747
const schemaName = getSchemaNameFromRef(apiResponseObject.$ref);
4848
const responseSchema = resolveObject(oas, ['components', 'responses', schemaName]);
49+
if(!responseSchema){
50+
return [{ path, message: `${errorCode} response must define content with a valid reference.` }];
51+
}
4952
content = responseSchema.content;
5053
} else {
5154
return [{ path, message: `${errorCode} response must define content with ApiError schema reference.` }];

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

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -42,11 +42,6 @@ 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-
5045
return objectPath.reduce((current, key) => {
5146
return current && current[key] ? current[key] : undefined;
5247
}, oas);

0 commit comments

Comments
 (0)