Skip to content

refactor: split normalizer/denormalizer#7713

Merged
soyuka merged 6 commits intoapi-platform:mainfrom
soyuka:denormalizer
May 7, 2026
Merged

refactor: split normalizer/denormalizer#7713
soyuka merged 6 commits intoapi-platform:mainfrom
soyuka:denormalizer

Conversation

@soyuka
Copy link
Copy Markdown
Member

@soyuka soyuka commented Jan 28, 2026

Q A
Branch? main
Tickets prerequisite for #7710
License MIT
Doc PR na

@soyuka soyuka force-pushed the denormalizer branch 3 times, most recently from a551716 to ea40daf Compare January 29, 2026 15:16
* @author Amrouche Hamza <hamza.simperfit@gmail.com>
* @author Baptiste Meyer <baptiste.meyer@gmail.com>
*
* @todo Denormalization methods should be deprecated in 5.x, use ItemDenormalizer instead
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should ItemNormalizer::denormalize call ItemDenormalizer::denormalize to ensure that futur bugfix/feature will be done on both ?

Cause we're having duplicate code with denormalize no ?

public const FORMAT = 'jsonapi';

private array $componentsCache = [];
use ItemNormalizerTrait;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there some methods to remove here ?
Like supportsDenormalization which is already in the trait if I read correctly

*
* @throws NotNormalizableValueException
*
* @todo This method should be deprecated in 5.x, use ItemDenormalizer instead
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same, could it call ItemDenormalizer::denormalize ?

@stale
Copy link
Copy Markdown

stale Bot commented Apr 3, 2026

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.

@stale stale Bot added the stale label Apr 3, 2026
@soyuka soyuka added enhancement and removed stale labels Apr 6, 2026
@soyuka soyuka force-pushed the denormalizer branch 6 times, most recently from 6772b9e to 2799be4 Compare May 6, 2026 08:39
soyuka added 3 commits May 6, 2026 14:17
| Q             | A
| ------------- | ---
| Branch?       | main
| Tickets       | prerequisite for api-platform#7710
| License       | MIT
| Doc PR        | ∅

Extract a dedicated ItemDenormalizer alongside each ItemNormalizer
(generic Serializer, JSON-LD, JSON:API) with shared logic in an
ItemNormalizerTrait. Existing normalizers keep their denormalize
support via the trait for BC. Symfony and Laravel DI register the
new denormalizers.
The normalizer/denormalizer split accidentally dropped this override.
Without it, JsonApi\Serializer\ItemNormalizer inherits the parent's
generic implementation (returns ['object' => false] for any format),
which breaks Symfony Serializer fast-path routing — a more generic
normalizer can win for formats that should land on the JSON:API one.

Restored to the same shape kept by JsonLd\Serializer\ItemNormalizer
post-split, matching the pre-split behavior.
soyuka added 2 commits May 6, 2026 16:29
#[IgnoreDeprecations] is required alongside expectUserDeprecationMessage()
so --fail-on-deprecation does not flag the asserted deprecation in
serializer/json-api ItemNormalizer/ItemDenormalizer tests.
Mirrors the split done for Serializer/JsonApi/JsonLd: introduces
GraphQl\Serializer\ItemDenormalizer registered at priority -889 so
Symfony's serializer dispatches mutation denormalization to it,
avoiding the legacy ItemNormalizer::denormalize() deprecation.
@soyuka soyuka merged commit d36c14c into api-platform:main May 7, 2026
118 of 119 checks passed
@soyuka soyuka deleted the denormalizer branch May 7, 2026 11:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants