diff --git a/openapi3filter/req_resp_decoder.go b/openapi3filter/req_resp_decoder.go index c509def3e..31fce2346 100644 --- a/openapi3filter/req_resp_decoder.go +++ b/openapi3filter/req_resp_decoder.go @@ -320,6 +320,10 @@ func decodeValue(dec valueDecoder, param string, sm *openapi3.SerializationMetho switch { case schema.Value.Type.Is("array"): decodeFn = func(param string, sm *openapi3.SerializationMethod, schema *openapi3.SchemaRef) (any, bool, error) { + res, b, e := dec.DecodeArray(param, sm, schema) + if len(res) == 0 { + return nil, b, e + } return dec.DecodeArray(param, sm, schema) } case schema.Value.Type.Is("object"): diff --git a/openapi3filter/req_resp_decoder_test.go b/openapi3filter/req_resp_decoder_test.go index 6e456d2aa..53763901d 100644 --- a/openapi3filter/req_resp_decoder_test.go +++ b/openapi3filter/req_resp_decoder_test.go @@ -878,6 +878,22 @@ func TestDecodeParameter(t *testing.T) { want: map[string]any{"id": "foo", "name": "bar"}, found: true, }, + { + name: "no param, for arrays", + param: &openapi3.Parameter{Name: "something", In: "query", Schema: stringArraySchema}, + query: "", + want: nil, + found: false, + err: nil, + }, + { + name: "missing param, for arrays", + param: &openapi3.Parameter{Name: "something", In: "query", Schema: stringArraySchema}, + query: "foo=bar", + want: nil, + found: false, + err: nil, + }, { name: "deepObject explode additionalProperties with object properties - missing index on nested array", param: &openapi3.Parameter{