-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[Serializer] Add context for CamelCaseToSnakeCaseNameConverter
#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 our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Serializer] Add context for CamelCaseToSnakeCaseNameConverter
#53898
Conversation
Please add a test case to avoid further regression, thanks |
1373073
to
45edbbb
Compare
src/Symfony/Component/Serializer/Tests/NameConverter/CamelCaseToSnakeCaseNameConverterTest.php
Outdated
Show resolved
Hide resolved
src/Symfony/Component/Serializer/Tests/NameConverter/CamelCaseToSnakeCaseNameConverterTest.php
Outdated
Show resolved
Hide resolved
CamelCaseToSnakeCaseNameConverter
796cf00
to
6bf22cf
Compare
4569651
to
b2c5e57
Compare
f871772
to
75b0805
Compare
src/Symfony/Component/HttpKernel/Controller/ArgumentResolver/RequestPayloadValueResolver.php
Outdated
Show resolved
Hide resolved
75b0805
to
04e22ec
Compare
Thank 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 | MIT Add missing changelog in my PR merged today : #53898 Commits ------- 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 | MIT Commits ------- 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 | Fix symfony/symfony#53898 (comment) | License | MIT Commits ------- d088047dfa add $class, $format and $context arguments to NameConverterInterface methods
Currently, when we use a Symfony 7.0 project (or 6.4 for example) with the
symfony/serializer
component installed.With the
#[MapRequestPayload]
feature and this configuration :This configuration forces Symfony to return to the snake case format.
But when sending these two
POST
requests :They will be handled exactly the same.
The idea is to add a context
CamelCaseToSnakeCaseNameConverter::REQUIRE_SNAKE_CASE_PROPERTIES
which can be used in#[MapRequestPayload]
attribute to only accept thePOST
request withlast_name
attribute 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.