api-platform / docs

API Platform documentation
https://api-platform.com/docs/
164 stars 1.05k forks source link

Update state-providers.md #1951

Open gonzaloalonsod opened 2 months ago

gonzaloalonsod commented 2 months ago

Return JsonResponse

gonzaloalonsod commented 2 months ago

This change doesn't look good to me.

The provider must return an object that will be handled by the serializer, not a HTTP response.

"Returns an empty DTO, does not serialize the object. Should it be explicit when serializing? Do you have an example?"

dunglas commented 2 months ago

This shouldn't return an empty object. The serialization is done automatically, no need to do it explicitly. This example should work.