-
-
Notifications
You must be signed in to change notification settings - Fork 900
allow_extra_attributes and update nested entity @id #6225
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
Labels
Comments
specify this inside the normalizerContext? |
Yes, ili101@7b84701 then you can: #[ApiResource(
denormalizationContext: [
AbstractNormalizer::GROUPS => ['Main:write'],
'additional_allowed_attributes' => ['@id', '@type', 'id', '@context'],
],
)] |
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. |
can you let me know if my patch works |
Looks good |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Description
As mentioned in documentation https://api-platform.com/docs/core/serialization/#denormalization
When setting
allow_extra_attributes: false
this results inExtra attributes are not allowed ("@id" is unknown).
If using json and not ld+json and sending
id
instead you get the same error onid
.P.S. not sure if intentional but for the update to actually work even if extra attributes allowed
@id
needs to also be provided on the parent entity.How to reproduce
Test example https://github.com/ili101/api-platform/blob/subTest/Test.ps1 (uncomment
allow_extra_attributes
in api_platform.yaml)Possible Solution
Allow
@id
(or maybe also@type
@context
) withallow_extra_attributes: false
and ld+json.Allow
id
withallow_extra_attributes: false
and json.Alternatively for more flexible solution, in the Entry ApiProperty or somewhere else add and option to set the base
$allowedAttributes
with default values here:core/src/Serializer/AbstractItemNormalizer.php
Line 423 in 5523bf5
Something like:
Additional Context
api-platform/api-platform#2096
api-platform/api-platform#2620
https://stackoverflow.com/questions/70379382/how-to-update-nested-entity-with-api-platform
The text was updated successfully, but these errors were encountered: