-
-
Notifications
You must be signed in to change notification settings - Fork 900
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
Conversation
} | ||
|
||
$uriVariables = $context['uri_variables']; | ||
$uriVariables = $context['uri_variables'] ?? $data; |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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" | ||
} | ||
""" |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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 PUT
s... I'm going to reproduce the scenario...
} | ||
|
||
return $context; | ||
} |
There was a problem hiding this comment.
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
?
There was a problem hiding this comment.
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 👏!
fixes #5736