Open ko2in opened 3 years ago
This was the case in 1.x but we refactored the param fetcher in 2.0 and the default value is not longer type casted to array since. I think the issue here is that the docs are outdated, PR welcome if you'd like to fix them :)
I believe this decision was taken to allow default values with a different type. You can fix your code with:
/**
* @FOS\QueryParam(map=true, name="ids", requirements="\d+", default=["1"], description="List of ids")
*/
According to the documentation, when mapping the value as array, the param fetcher will validate each entries of array with the requirements and replace with default value if each entry is invalid.
But, it replaces the whole array with the default value (1) as string.
The documentation says:
If ids is not defined, array(1) will be given
, but it returns the default value as string (1).Here's the test results with my REST client.
Below is my sample code in controller: