Skip to content

Commit

Permalink
Merge 5a08be3 into 79ff03e
Browse files Browse the repository at this point in the history
  • Loading branch information
k1LoW authored Apr 28, 2024
2 parents 79ff03e + 5a08be3 commit a277ee7
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions openapi3.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"strconv"
"strings"

validator "github.com/pb33f/libopenapi-validator"
verrors "github.com/pb33f/libopenapi-validator/errors"
"gopkg.in/yaml.v3"
)
Expand Down Expand Up @@ -65,6 +66,17 @@ func (rt *Router) setOpenApi3Vaildator() error {
if !rt.skipValidateRequest {
_, errs := v.ValidateHttpRequest(r)
if len(errs) > 0 {
{
// renew validator (workaround)
// ref: https://github.com/k1LoW/runn/issues/882
vv, errrs := validator.NewValidator(*rt.openAPI3Doc)
if len(errrs) > 0 {
rt.t.Errorf("failed to renew validator: %v", errors.Join(errrs...))
return
}
rt.openAPI3Validator = &vv
v = *rt.openAPI3Validator
}
var err error
for _, e := range errs {
// nullable type workaround.
Expand All @@ -82,6 +94,16 @@ func (rt *Router) setOpenApi3Vaildator() error {
if !rt.skipValidateResponse {
_, errs := v.ValidateHttpResponse(r, rec.toResponse())
if len(errs) > 0 {
{
// renew validator (workaround)
// ref: https://github.com/k1LoW/runn/issues/882
vv, errrs := validator.NewValidator(*rt.openAPI3Doc)
if len(errrs) > 0 {
rt.t.Errorf("failed to renew validator: %v", errors.Join(errrs...))
return
}
rt.openAPI3Validator = &vv
}
var err error
for _, e := range errs {
// nullable type workaround.
Expand Down

0 comments on commit a277ee7

Please sign in to comment.