Skip to content

fix(serializer): use data if no uri_variables provided #5743

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

Merged
merged 1 commit into from
Aug 11, 2023

Conversation

soyuka
Copy link
Member

@soyuka soyuka commented Aug 11, 2023

fixes #5736

}

$uriVariables = $context['uri_variables'];
$uriVariables = $context['uri_variables'] ?? $data;
Copy link
Member Author

Choose a reason for hiding this comment

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

@Aerendir can you try this?

Copy link
Contributor

Choose a reason for hiding this comment

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

Hi @soyuka , I've tried the fix, but it doesn't work...

In ItemNormalizer::getContextUriVariables(), there is no key $context['uri_variables'], so the variable $uriVariable gets the value of $data, but $data contains the entity and so there will never be the uri variables needed.

I'm going to reproduce in tests what's going on...

"betaId": 1,
"alpha": "/alphas/2"
}
"""
Copy link
Member Author

Choose a reason for hiding this comment

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

@Aerendir this works right now so I'm not sure what the issue is, are you using merge-patch?

Copy link
Contributor

Choose a reason for hiding this comment

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

@soyuka , no, I'm using PUTs... I'm going to reproduce the scenario...

}

return $context;
}
Copy link
Member Author

Choose a reason for hiding this comment

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

@jonag can you try this and use root_operation?

Copy link
Contributor

Choose a reason for hiding this comment

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

Updating to API Platform v3.1.14 and changing my custom normalizer to use the root_operation instead of the operation fixes all my tests!
Thank you 👏!

@soyuka soyuka merged commit 4f9626f into api-platform:3.1 Aug 11, 2023
@soyuka soyuka deleted the fix/serializer branch August 11, 2023 14:19
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.

3 participants