-
-
Notifications
You must be signed in to change notification settings - Fork 486
Description
Hi,
I noticed some inconsistencies while using arrays in query.
When the schema is an array and;
- The query is empty, the function returns nil
- The query is not empty, the function returns []interface{nil}
This can be reproduced with the following test cases (to add in https://github.com/getkin/kin-openapi/blob/master/openapi3filter/req_resp_decoder_test.go#L859 ) :
{
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, // Will fail
found: false,
err: nil,
},
This is due to the first case returning nil via this condition: https://github.com/getkin/kin-openapi/blob/master/openapi3filter/req_resp_decoder.go#L248
While the second case returns nil via this condition https://github.com/getkin/kin-openapi/blob/master/openapi3filter/req_resp_decoder.go#L524 (that function returns a []any, thus the nil is wrapped in a slice