Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion pkg/middleware/oapi_validate.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import (
"fmt"
"io/ioutil"
"net/http"
"strings"

"github.com/getkin/kin-openapi/openapi3"
"github.com/getkin/kin-openapi/openapi3filter"
Expand Down Expand Up @@ -116,7 +117,10 @@ func ValidateRequestFromContext(ctx echo.Context, router *openapi3filter.Router,
switch e := err.(type) {
case *openapi3filter.RequestError:
// We've got a bad request
return echo.NewHTTPError(http.StatusBadRequest, e.Reason)
// Split up the verbose error by lines and return the first one
// openapi errors seem to be multi-line with a decent message on the first
errorLines := strings.Split(e.Error(), "\n")
return echo.NewHTTPError(http.StatusBadRequest, errorLines[0])
case *openapi3filter.SecurityRequirementsError:
return echo.NewHTTPError(http.StatusForbidden, e.Error())
default:
Expand Down