Repository navigation
fix(jsonapi): denormalize sparse fieldset names with the name converter - #8861
Merged
soyuka merged 2 commits intoNov 20, 2026
Merged
Conversation
Contributor
Author
|
Thanks for merging, and for the comment cleanup. I'll keep comments out of tests next time. |
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.
With a name converter,
SparseFieldsetParameterProvidercompared the field names sent by the client (artist_credit) with the PHP property names (artistCredit), so every converted field was dropped fromfields[TYPE]. It now denormalizes each requested field throughapi_platform.name_converterbefore matching it and adding it to the whitelist, asPropertyFilterdoes. The converter is an optional last constructor argument, so the change is backward compatible; the Symfony service passes it withignoreOnInvalid(), like the other services that use it.The functional test is
tests/Functional/JsonApi/SparseFieldsetNameConverterTest.php. It uses a new fixture,SparseFieldsetNameConverted, and the test app'sCustomConverter, which serializesnameConvertedasname_converted:Without the fix,
name_convertedis missing from the attributes and the test fails. With the fix, it passes. A unit test was also added toSparseFieldsetParameterProviderTest(testFieldsAreDenormalizedWithTheNameConverter), and PHPStan reports no errors on the provider.The second case in the issue (
stateOptionslimiting the primary type to the entity's properties) is left out. Building the allowed properties from the resource class would also widen apropertieslist set explicitly on the parameter, so that change needs a maintainer decision first.