Skip to content

Commit a61e37f

Browse files
committed
fix: change output format for method
1 parent ad75fa4 commit a61e37f

File tree

2 files changed

+5
-7
lines changed

2 files changed

+5
-7
lines changed

tools/spectral/CONTRIBUTING.md

Whitespace-only changes.

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

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ export default (input, _, { path }) => {
2525

2626
// 3. Validation
2727
const errors = checkViolations(deleteOp.responses);
28-
if (errors) {
28+
if (errors.length > 0) {
2929
return collectAndReturnViolation(path, RULE_NAME, errors);
3030
}
3131

@@ -35,27 +35,25 @@ export default (input, _, { path }) => {
3535
/**
3636
* Check if the operation has validation issues
3737
* @param {object} input - The object to vefify
38-
* @return {Array<string>|undefined} - The content types that have a schema
38+
* @return {Array<string>} - errors array (empty if no errors)
3939
*/
4040
function checkViolations(input) {
41+
const errors = [];
4142
try {
4243
if (input && input['204']) {
4344
const successResponse = input['204'];
4445
if (successResponse.content) {
45-
const errors = [];
4646
for (const contentType of Object.keys(successResponse.content)) {
4747
if (successResponse.content[contentType] && successResponse.content[contentType].schema) {
4848
errors.push({
4949
message: `Error found for ${contentType}: ${ERROR_MESSAGE}`,
5050
});
5151
}
5252
}
53-
return errors.length > 0 ? errors : undefined;
5453
}
5554
}
5655
} catch (e) {
57-
return ['Internal Rule Error without reporting violation' + e];
56+
return [`${RULE_NAME} Internal Rule Error: ${e} Please report issue in https://github.com/mongodb/openapi/issues`];
5857
}
59-
// No errors returning undefined
60-
return undefined;
58+
return errors;
6159
}

0 commit comments

Comments
 (0)