swagger-express-middleware
swagger-express-middleware copied to clipboard
Provide granular error output customization
currently, we have two properties on error, error.status
and error.message
. I'd like to propose that additional properties be added, so that the error messages can be better customized.
if the error object passed to the error handler function had a more granular structure, users could provide nicer error message.
For example, today the error.message
for validation error will output something like this:
message The "body" body parameter is invalid ({"name":"june","location":{},"group":"","district":""})
JSON Schema validation error.
Data path: "/location"
Schema path: "/properties/location/required/0"
Missing required property: geo
It's quite verbose
I'd like to customize it to instead say something more succinct e.g.
Missing required property: /location/geo
Adding additional properties and/or changing the message makes this possible
{
"type": "validation error",
"message": "missing required fields",
"property": "/location/geo"
}
and for a constraint mismatch
{
"type": "validation error",
"message": "expected object, got string",
"property": "address",
}
etc...
The above structure (and messaging) needs a bit more thought, but you see where im gong
@cdimascio Any resolution on this issue?