@@ -5,8 +5,10 @@ import (
55 "encoding/json"
66 "fmt"
77 "net/http"
8+ "sort"
89 "strings"
910
11+ "github.com/getkin/kin-openapi/openapi3"
1012 "github.com/getkin/kin-openapi/openapi3filter"
1113 "github.com/labstack/echo/v4"
1214)
@@ -130,8 +132,30 @@ func (h *Handler) validate(c echo.Context, code int, contentType string, v any)
130132 ctx := context .Background ()
131133 err = openapi3filter .ValidateResponse (ctx , responseValidationInput )
132134 if err != nil {
133- c .Logger ().Error (err )
134- return fmt .Errorf ("failed validating response: %v" , err )
135+ switch err := err .(type ) {
136+ case nil :
137+ case * openapi3filter.ResponseError :
138+ if me , ok := err .Err .(openapi3.MultiError ); ok {
139+ issues := convertError (me )
140+ names := make ([]string , 0 , len (issues ))
141+
142+ for k := range issues {
143+ names = append (names , k )
144+ }
145+ sort .Strings (names )
146+ var errors []string
147+ for _ , k := range names {
148+ msgs := issues [k ]
149+ for _ , msg := range msgs {
150+ errors = append (errors , msg )
151+ }
152+ }
153+
154+ return fmt .Errorf ("failed validating response: %s" , strings .Join (errors , "; " ))
155+ }
156+ default :
157+ return fmt .Errorf ("failed validating response: %v" , err )
158+ }
135159 }
136160
137161 return c .Blob (code , h .Config .ContentType , b )
0 commit comments