Description
API Platform version(s) affected: 2.5.6
Description
Hi, I have a concern that Json:Api response formatting isn’t working properly if an output class is being used for API resource (“relationships”, “links”, “meta”, "included" fields are missing)
A check if the output class is being used is performed here:
and if it is, an AbstractItemNormalizer->normalize() method is called.
Data is then transformed and execution proceeds as such:
AbstractItemNormalizer->normalize() =>
Symfony/Serializer->normalize() =>
JsonApi/ObjectNormalizer->normalize()
In the JsonApi/ObjectNormalizer->normalize() Json:Api specific fields are added (“id”, “type”, “attributes”)
My concern is that the code below the if-statement linked above never gets executed.
This results in the resource metadata (links, meta, relationships) not being applied to the response object.
Can someone please help understand is this actually the case or I’m misinterpreting something?
Thanks 😃
How to reproduce
- Mark an API resource with "output" option
- Add an OutputTransformer that creates an output class and returns it
- Send GET request to retrieve your resource with a header "accept":"application/vnd.api+json"
If these steps are not enough, I can provide code snippets.