-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[Serializer] Alias for attributes #15171
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
Comments
I've started a POC about that. It's very similar to what you describe. It uses a new name converter that |
@dunglas Kevin, do you want me to contribute the code? It should be fairly simple to implement i assume. |
any news for this feature? |
@IndraGunawan the feature was in development by @dunglas in #15200, but was closed in favor of #18016, that for me is not the same |
Hey guys, Best regards. |
…properties through metadata (fbourigault) This PR was squashed before being merged into the 4.2-dev branch (closes #28505). Discussion ---------- [Serialized] allow configuring the serialized name of properties through metadata | Q | A | ------------- | --- | Branch? | master | Bug fix? | no | New feature? | yes | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | #15171 | License | MIT | Doc PR | symfony/symfony-docs#10422 This leverage the new `AdvancedNameConverterInterface` interface (#27021) to implement a name converter that relies on metadata. The name to use is configured per property using a `@SerializedName` annotation or the `serialized-name` XML attribute or the `serialized_name` key for YAML. This was exposed by @dunglas in #19374 (comment). # Framework integration For FramworkBundle integration, a ChainNameConverter could be added to allow users to use this name converter with a custom one. # To do - [x] add a CHANGELOG.md entry. - [x] add a fallback. - [x] add framework integration. - [x] add local caching to `MetadataAwareNameConverter`. - [x] add a doc PR. Commits ------- d1d1ceb [Serialized] allow configuring the serialized name of properties through metadata
@javiereguiluz this one could be closed since #28505 is merged and released. |
Closing as fixed then. Thanks! |
It would be very helpful to have the possibility to specify an alias for an attribute. This is the same as
serialized_name
in JMSSerializer".Here is an example YAML:
I wonder about the general take on this.
This was also mentioned in #14924 .
My current workaround is using a custom NameConverter.
The text was updated successfully, but these errors were encountered: