diff --git a/openapi3filter/validate_request.go b/openapi3filter/validate_request.go index 4b0bd3413..bde704c1d 100644 --- a/openapi3filter/validate_request.go +++ b/openapi3filter/validate_request.go @@ -272,8 +272,9 @@ func ValidateRequestBody(ctx context.Context, input *RequestValidationInput, req Err: err, } } - - if defaultsSet { + // only encode defaults for existing encoders + _, ok := bodyEncoders[mediaType] + if defaultsSet && ok { var err error if data, err = encodeBody(value, mediaType); err != nil { return &RequestError{