You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Description
On a Collection Get resource with Pagination plugin, when the collection is empty, the expected body should be an empty array. Both json & ld+json was working before 5.1.x
On this version of Symfony, now it will no more normalize the Paginator, but will just return the object and the response will be an empty object like this "{}" instead of the empty array like this "[]"
The problem comes from the Symfony\Component\Serializer\Serializer::normalize.
Before 5.1.0 it does this:
API Platform version(s) affected: v2.5.6
Description
On a Collection Get resource with Pagination plugin, when the collection is empty, the expected body should be an empty array. Both json & ld+json was working before 5.1.x
On this version of Symfony, now it will no more normalize the Paginator, but will just return the object and the response will be an empty object like this "{}" instead of the empty array like this "[]"
The problem comes from the Symfony\Component\Serializer\Serializer::normalize.
Before 5.1.0 it does this:
Since Symfony 5.1.0 it also adds a check on data lenght like this:
How to reproduce
With a simple DataProvider that implements CollectionDataProviderInterface and which query returns nothing (add a where 1 = 0) :
Possible Solution
No solution for instance
Additional Context
Json response before 5.1 :
[]
Json response after 5.1 :
{}
The text was updated successfully, but these errors were encountered: