Open
Description
When validating the query params of an endpoint with parameters of type array we get a validation error:
Example:
GET /api/users?ids[]=1&ids[]=2
Operation param defined as:
Operation.parameter(
:"ids[]",
:query,
%Schema{type: :array, items: %Schema{type: :integer}},
"IDs"
)
We get the following error:
[
%OpenApiSpex.Cast.Error{
reason: :invalid_type,
value: "2",
format: nil,
type: :array,
name: nil,
path: [:ids],
length: 0,
meta: %{}
}
]
This is because Plug.Conn.fetch_query_params
removes the "[]" part by grouping the property and returning an array of results. Following the example above, the result of this function would be %{ids: [1,2]}
which causes an error, because in the Schema "ids[]" has been defined as a possible parameter and not "ids".
Metadata
Metadata
Assignees
Labels
No labels