Skip to content

Commit

Permalink
Add workaround for invalid validator instance after validation error.
Browse files Browse the repository at this point in the history
ref: #882
  • Loading branch information
k1LoW committed Apr 21, 2024
1 parent c0c7714 commit 5477b40
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions http_validator.go
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,15 @@ func (v *openAPI3Validator) ValidateRequest(ctx context.Context, req *http.Reque
vv := *v.doc.validator
_, errs := vv.ValidateHttpRequest(req)
if len(errs) > 0 {
{
// renew validator (workaround)
// ref: https://github.com/k1LoW/runn/issues/882
vv, errrs := validator.NewValidator(*v.doc.doc)
if len(errrs) > 0 {
return errors.Join(errrs...)
}
v.doc.validator = &vv
}
var err error
for _, e := range errs {
// nullable type workaround.
Expand Down Expand Up @@ -194,6 +203,15 @@ func (v *openAPI3Validator) ValidateResponse(ctx context.Context, req *http.Requ
vv := *v.doc.validator
_, errs := vv.ValidateHttpResponse(req, res)
if len(errs) > 0 {
{
// renew validator (workaround)
// ref: https://github.com/k1LoW/runn/issues/882
vv, errrs := validator.NewValidator(*v.doc.doc)
if len(errrs) > 0 {
return errors.Join(errrs...)
}
v.doc.validator = &vv
}
var err error
for _, e := range errs {
// nullable type workaround.
Expand Down

0 comments on commit 5477b40

Please sign in to comment.