-
-
Notifications
You must be signed in to change notification settings - Fork 888
This issue was moved to a discussion.
You can continue the conversation there. Go to discussion →
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
JsonApi attributes are missing when using an Output class #3590
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 |
It's intended indeed as our normalizer only handles classes marked as History of the work on this topic: |
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. |
This issue was moved to a discussion.
You can continue the conversation there. Go to discussion →
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.
The text was updated successfully, but these errors were encountered: