oapi-codegen
oapi-codegen copied to clipboard
Make OpenAPI Validator `ErrorHandler` take an `error` not a `message`
When writing handler functions for the OpenAPI Validation Middleware, it's a little odd that we get i.e.:
api.GorillaServerOptions{
ErrorHandlerFunc: func(w http.ResponseWriter, r *http.Request, err error) {
But then we only receive the message in the top-level Options:
https://github.com/deepmap/oapi-codegen/blob/9a9e66fe11c82b21732777233127d518ad092481/pkg/chi-middleware/oapi_validate.go#L19-L20
We should modify it to provide the full error, then it can be i.e. shipped to a logging platform as-is, with information about what the error type is.
This would be a breaking change, so it'd be best to be a new method, and then we can deprecate the message-only version.
It could be useful to provide the request as well. I need to use request.Context().