Replies: 3 comments
-
Hi! I've just run into this also. As soon as you use public function normalize($object, $format = null, array $context = [])
{
if (!($isTransformed = isset($context[self::IS_TRANSFORMED_TO_SAME_CLASS])) && $outputClass = $this->getOutputClass($this->getObjectClass($object), $context)) {
// ...
return $this->serializer->normalize($transformed, $format, $context);
}
// the rest of the normal logic that's used for normalization, including
// calling parent::normalize() (AbstractObjectNormalizer) which has a TON of logic
// related to circular references, max depth and using ApiPlatform's PropertyMetadataFactory
// to assist in fetching the values of attributes and normalizing collections/embedded ApiResources
} Effectively, by choosing an On a more practical note, if you use JSON-LD, you get the |
Beta Was this translation helpful? Give feedback.
-
It's intended indeed as our normalizer only handles classes marked as History of the work on this topic: |
Beta Was this translation helpful? Give feedback.
-
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
Beta Was this translation helpful? Give feedback.
-
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:
core/src/JsonApi/Serializer/ItemNormalizer.php
Line 71 in 9ccf578
and if it is, an AbstractItemNormalizer->normalize() method is called.
Data is then transformed and execution proceeds as such:
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
If these steps are not enough, I can provide code snippets.
Beta Was this translation helpful? Give feedback.
All reactions