Skip to content

fix: Allow nested denormalization when allow_extra_attributes=false #7270

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

Open
wants to merge 3 commits into
base: 4.1
Choose a base branch
from

Conversation

calbro7
Copy link

@calbro7 calbro7 commented Jul 1, 2025

Q A
Branch? 4.1
Tickets Resolves #6225
License MIT

The linked issue was resolved for JSON LD format with #6451 but not for standard JSON, so this PR implements the same change in the standard ItemNormalizer.

The included test file demonstrates the expected behaviour, it should be possible to alter the Bar entity's someProperty via a PATCH request to edit its parent Foo object.

This test passes with the ItemNormalizer change, but fails without it due to Extra attributes are not allowed (\"id\" is unknown)..

First contribution so let me know if I've done things correctly or if I've missed anything needed for approval!

@calbro7 calbro7 changed the title fix(jsonld): reset gen_id configuration fix: Allow nested denormalization when allow_extra_attributes=false Jul 1, 2025
{
$allowedAttributes = parent::getAllowedAttributes($classOrObject, $context, $attributesAsString);
if (\is_array($allowedAttributes) && ($context['api_denormalize'] ?? false)) {
$allowedAttributes = array_merge($allowedAttributes, ['id']);
Copy link
Member

Choose a reason for hiding this comment

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

what if id isn't the property/attribute used to identify a resource?

@soyuka
Copy link
Member

soyuka commented Jul 2, 2025

This looks like it breaks one of our test would you be able to identify why? Inside CONTRIBUTING there's everything you need to run tests.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants