From fffa5c77bfac9865eb3442a02203b57db2c99968 Mon Sep 17 00:00:00 2001 From: Pierre Fenoll Date: Thu, 13 Oct 2022 11:23:59 +0200 Subject: [PATCH] wip Signed-off-by: Pierre Fenoll --- openapi3filter/req_resp_decoder_test.go | 2 +- openapi3filter/validate_request.go | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/openapi3filter/req_resp_decoder_test.go b/openapi3filter/req_resp_decoder_test.go index 8bd62b1c5..16a02a047 100644 --- a/openapi3filter/req_resp_decoder_test.go +++ b/openapi3filter/req_resp_decoder_test.go @@ -1053,7 +1053,7 @@ func TestDecodeParameter(t *testing.T) { require.NoError(t, err) input := &RequestValidationInput{Request: req, PathParams: pathParams, Route: route} - got, found, err := decodeStyledParameter(tc.param, input) + got, found, err := decodeStyledParameter(tc.param, input, tc.param.Schema) require.Truef(t, found == tc.found, "got found: %t, want found: %t", found, tc.found) diff --git a/openapi3filter/validate_request.go b/openapi3filter/validate_request.go index b6db856a6..296728af0 100644 --- a/openapi3filter/validate_request.go +++ b/openapi3filter/validate_request.go @@ -139,9 +139,10 @@ func ValidateParameter(ctx context.Context, input *RequestValidationInput, param err = fmt.Errorf("multiple content types for parameter %q", parameter.Name) return &RequestError{Input: input, Parameter: parameter, Err: err} } else { - mt := parameter.Content.Get("application/json") + const ct = "application/json" + mt := parameter.Content.Get(ct) if mt == nil { - err = fmt.Errorf("parameter %q has no content schema", parameter.Name) + err = fmt.Errorf("parameter %q has no content schema for %q", parameter.Name, ct) return &RequestError{Input: input, Parameter: parameter, Err: err} } schemaRef = mt.Schema