Skip to content

Commit

Permalink
Add try catch in case invalid/missing content type is passed
Browse files Browse the repository at this point in the history
  • Loading branch information
jordandobrev committed Apr 13, 2020
1 parent 362d988 commit 28a3d5e
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions src/middlewares/openapi.response.validator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -154,12 +154,16 @@ export class ResponseValidator {
throw validationError(500, '.response', 'response body required.');
}

// // CHECK If Content-Type is validatable
// if (!this.canValidateContentType(contentType)) {
// console.warn('Cannot validate content type', contentType);
// // assume valid
// return;
// }
// CHECK If Content-Type is validatable
try {
if (!this.canValidateContentType(contentType)) {
console.warn('Cannot validate content type', contentType);
// assume valid
return;
}
} catch (e) {
// Do nothing. Move on and validate response
}

const valid = validator({
response: body,
Expand Down

0 comments on commit 28a3d5e

Please sign in to comment.