From 8cb87337570759695419275033d3595118d060c8 Mon Sep 17 00:00:00 2001 From: Hut Date: Fri, 4 Nov 2022 16:31:10 -0700 Subject: [PATCH] only encode defaults for supported content type --- openapi3filter/validate_request.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) 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{