Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork9.7k
[Serializer] Add context forCamelCaseToSnakeCaseNameConverter#53898
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
[Serializer] Add context forCamelCaseToSnakeCaseNameConverter#53898
Uh oh!
There was an error while loading.Please reload this page.
Conversation
Please add a test case to avoid further regression, thanks |
1373073 to45edbbbComparesrc/Symfony/Component/Serializer/Tests/NameConverter/CamelCaseToSnakeCaseNameConverterTest.php OutdatedShow resolvedHide resolved
Uh oh!
There was an error while loading.Please reload this page.
src/Symfony/Component/Serializer/Tests/NameConverter/CamelCaseToSnakeCaseNameConverterTest.php OutdatedShow resolvedHide resolved
Uh oh!
There was an error while loading.Please reload this page.
CamelCaseToSnakeCaseNameConverter796cf00 to6bf22cfCompare4569651 tob2c5e57Comparef871772 to75b0805Comparesrc/Symfony/Component/HttpKernel/Controller/ArgumentResolver/RequestPayloadValueResolver.php OutdatedShow resolvedHide resolved
Uh oh!
There was an error while loading.Please reload this page.
75b0805 to04e22ecCompareThank you@AurelienPillevesse. |
This PR was merged into the 7.1 branch.Discussion----------Add missing changelog for PR53898| Q | A| ------------- | ---| Branch? | 7.1| Bug fix? | no| New feature? | yes| Deprecations? | no| Issues | -| License | MITAdd missing changelog in my PR merged today :#53898Commits-------c86f689 add missing changelog for PR 53898
Isn't this is a bc-break as both interfaces (AdvancedNameConverterInterface and the NameConverterInterface) are not compatible and this class is not internal. One could extend the current |
symfony/symfony#53898 breaks our interface
Yes it is.@AurelienPillevesse can you please have a look? |
@nicolas-grekas How can we implement this feature without changing the interface ? |
I suggest that we add the arguments to the |
…to NameConverterInterface methods (xabbuh)This PR was merged into the 7.1 branch.Discussion----------[Serializer] add $class, $format and $context arguments to NameConverterInterface methods| Q | A| ------------- | ---| Branch? | 7.1| Bug fix? | no| New feature? | no| Deprecations? | no| Issues |Fix#53898 (comment)| License | MITCommits-------d088047 add $class, $format and $context arguments to NameConverterInterface methods
…to NameConverterInterface methods (xabbuh)This PR was merged into the 7.1 branch.Discussion----------[Serializer] add $class, $format and $context arguments to NameConverterInterface methods| Q | A| ------------- | ---| Branch? | 7.1| Bug fix? | no| New feature? | no| Deprecations? | no| Issues |Fixsymfony/symfony#53898 (comment)| License | MITCommits-------d088047dfa add $class, $format and $context arguments to NameConverterInterface methods
Uh oh!
There was an error while loading.Please reload this page.
Currently, when we use a Symfony 7.0 project (or 6.4 for example) with the
symfony/serializercomponent installed.With the
#[MapRequestPayload]feature and this configuration :This configuration forces Symfony to return to the snake case format.
But when sending these two
POSTrequests :{"lastName":"MyLastName"}{"last_name":"MyLastName"}They will be handled exactly the same.
The idea is to add a context
CamelCaseToSnakeCaseNameConverter::REQUIRE_SNAKE_CASE_PROPERTIESwhich can be used in#[MapRequestPayload]attribute to only accept thePOSTrequest withlast_nameattribute body.Example :
[Note]
This is a first draft to expose my idea. The exception thrown and where the new condition is added can probably be improved.
A possible improvement can be to use the existing logic with
PartialDenormalizationException.If for you it can added in 6.4 and 7.0 instead of 7.1, i'm OK.