Add test for updating embedded relation using plain identifier #3145
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.
Targeting
2.4
so that we're able to demonstrate that it works correctly on2.4
.Background:
Before #3036, the
$options
we pass to the PropertyNameCollectionFactory was wrong, because it was using the (Serializer)$context
directly. Specifically, the$context['groups']
were not translated to$options['serializer_groups']
, so they had no effect. (There could have been many bugs caused by that.)That bug fix however in turn revealed the problem with incorrect property metadata set on API resources in some projects (see for example #3133).
For example, the
id
property in the related resource is not in the serializer groups used for denormalization, which makes sense at first glance, because you don't want to allow updating theid
. However, theItemNormalizer
uses the property metadata to identify the correct identifier property, so it's actually required that theid
property must be part of the serializer groups used for denormalization (only applicable in the case of using plain identifiers, where you're sending theid
property). To disallow updating theid
, the correct solution is to use@ApiProperty(writable=false)
.