You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When additionalProperties validation fails, following error is thrown:
{stack: 'Error: request.body should NOT have additional properties\n at Object.POST-/api/....\n',message: 'request.body should NOT have additional properties',toJSON:[Function:toJSON],status: 400,errors: [{path:'.body',message:'should NOT have additional properties',errorCode:'additionalProperties.openapi.validation'}],name: 'Error',toString: [Function:toString]}
Is there any chance to add a list of additional properties to error message. It would be really helpfull to know, which properties should be removed from payload.
Information about additional properties is available in validator.errors array, generated by ajv validator (
Yes we should definitely make this available.
I'm away until next week. I will plan to look at this then. If someone contributes a fix in the meantime I'll certainly have a look.
@medolino instead of making the change next week, ive completed it today. check out v2.3.0
The path for each additionalProperty error will contain the offending field name; similar to required
When additionalProperties validation fails, following error is thrown:
Is there any chance to add a list of additional properties to error message. It would be really helpfull to know, which properties should be removed from payload.
Information about additional properties is available in
validator.errors
array, generated byajv
validator (express-openapi-validator/src/middlewares/openapi.request.validator.ts
Line 139 in bc50cc0
ajvErrorsToValidatorError
util function (express-openapi-validator/src/middlewares/util.ts
Line 34 in bc50cc0
Avj validation errors:
Customized error object provided by
ajvErrorsToValidatorError
:The text was updated successfully, but these errors were encountered: