Skip to content

Commit

Permalink
errors
Browse files Browse the repository at this point in the history
  • Loading branch information
Carmine DiMascio committed Jul 18, 2019
1 parent 61e3d30 commit e2e8b3e
Showing 1 changed file with 12 additions and 9 deletions.
21 changes: 12 additions & 9 deletions src/middlewares/openapi.request.validator.2.ts
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,12 @@ export class RequestValidator {
} else {
const errors = validator.errors;
const errorText = this.ajv.errorsText(errors, { dataVar: 'request' });
throw validationError(400, path, errorText, errors);

if (errors.length > 0) {
const message = errors[0].message;
throw ono(errors, message);
}
// throw validationError(400, path, errorText, errors);
// next(
// new AoavError(`Error while validating request: ${errorText}`, errors),
// );
Expand Down Expand Up @@ -227,10 +232,9 @@ export class RequestValidator {

const reqField = reqFields[$in];
if (!reqField) {
throw validationError(400, path, `Parameter 'in' has incorrect value '${$in}' for [${parameter.name}]`);
// throw new Error(
// `Parameter 'in' has incorrect value '${$in}' for [${parameter.name}]`,
// );
const message = `Parameter 'in' has incorrect value '${$in}' for [${parameter.name}]`;
const err = validationError(400, path, message);
throw ono(err, message);
}

let parameterSchema = parameter.schema;
Expand All @@ -240,10 +244,9 @@ export class RequestValidator {
}

if (!parameterSchema) {
throw validationError(400, path, `Not available parameter 'schema' or 'content' for [${parameter.name}]`,);
// throw new Error(
// `Not available parameter 'schema' or 'content' for [${parameter.name}]`,
// );
const message = `Not available parameter 'schema' or 'content' for [${parameter.name}]`
const err = validationError(400, path, message);
throw ono(err, message);
}

if (!schema[reqField].properties) {
Expand Down

0 comments on commit e2e8b3e

Please sign in to comment.