Skip to content

Commit 701059a

Browse files
authored
improve gin support (#530)
Co-authored-by: Zihao Zhang <z@zeet.co>
1 parent 2491c45 commit 701059a

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

oapi_validate.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,8 @@ func OapiRequestValidatorWithOptions(swagger *openapi3.T, options *Options) gin.
7272
err := ValidateRequestFromContext(c, router, options)
7373
if err != nil {
7474
// note: i am not sure if this is the best way to handle this
75+
// todo: the error message should be customizable by the user
76+
c.Error(err)
7577
c.AbortWithStatusJSON(http.StatusBadRequest, gin.H{"error": err.Error()})
7678
}
7779
c.Next()
@@ -124,6 +126,9 @@ func ValidateRequestFromContext(c *gin.Context, router routers.Router, options *
124126
errorLines := strings.Split(e.Error(), "\n")
125127
return fmt.Errorf("error in openapi3filter.RequestError: %s", errorLines[0])
126128
case *openapi3filter.SecurityRequirementsError:
129+
for _, e := range e.Errors {
130+
c.Error(e)
131+
}
127132
return fmt.Errorf("error in openapi3filter.SecurityRequirementsError: %s", e.Error())
128133
default:
129134
// This should never happen today, but if our upstream code changes,

0 commit comments

Comments
 (0)