fix(serializer): apply API Platform name converter to input/output DTOs#7779
Merged
soyuka merged 1 commit intoapi-platform:4.2from Feb 20, 2026
Merged
fix(serializer): apply API Platform name converter to input/output DTOs#7779soyuka merged 1 commit intoapi-platform:4.2from
soyuka merged 1 commit intoapi-platform:4.2from
Conversation
| Q | A | ------------- | --- | Branch? | main | Tickets | Fixes api-platform#7705 | License | MIT | Doc PR | ∅ After api-platform#7691 isolated AP's name converter, input/output DTOs lost it because supportsDenormalization/supportsNormalization rejected them on re-entry (the input/output context keys were unset). Context flags ensure AbstractItemNormalizer explicitly claims these DTOs. Co-Authored-By: Matteo Beccati <matteo@beccati.com> Co-Authored-By: Vincent Langlet <vincentlanglet@hotmail.fr> Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Contributor
|
The patch seems to be fixing my original use case, thanks |
Contributor
|
@soyuka This PR actually breaks certain Input DTO's like this (with no defaults to null options) <?php
readonly class UpdateAccount
{
public function __construct(
public readonly string $email,
public readonly ?string $firstName,
) {}
}
Reverting back to 4.2.16 it works. According to the symfony docs it by default $firstName should be null in this case: Changing it to this, it works. But it's not 100% BC <?php
readonly class UpdateAccount
{
public function __construct(
public readonly string $email,
public readonly ?string $firstName = null,
) {}
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
When denormalizing input DTOs, the serializer re-enters without the
inputcontext key, causingsupportsDenormalization()to reject the DTO. It falls through to Symfony's ObjectNormalizer which lacks AP's name converter. A newapi_platform_inputcontext flag ensures the DTO is handled by AbstractItemNormalizer.