Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork9.6k
[Serializer] Allow to add groups to SerializedName annotation/attribute#46432
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
base:7.4
Are you sure you want to change the base?
[Serializer] Allow to add groups to SerializedName annotation/attribute#46432
Uh oh!
There was an error while loading.Please reload this page.
Conversation
Uh oh!
There was an error while loading.Please reload this page.
src/Symfony/Component/Serializer/Mapping/Loader/YamlFileLoader.php OutdatedShow resolvedHide resolved
Uh oh!
There was an error while loading.Please reload this page.
carsonbot commentedMay 22, 2022
Hey! I think@mtarld has recently worked with this code. Maybe they can help review this? Cheers! Carsonbot |
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
src/Symfony/Component/Serializer/NameConverter/MetadataAwareNameConverter.php OutdatedShow resolvedHide resolved
Uh oh!
There was an error while loading.Please reload this page.
@mtarld I can't "Re request review" but changes are done |
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.
Almost good!
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
src/Symfony/Component/Serializer/Mapping/AttributeMetadataInterface.php OutdatedShow resolvedHide resolved
Uh oh!
There was an error while loading.Please reload this page.
src/Symfony/Component/Serializer/Mapping/Loader/YamlFileLoader.php OutdatedShow resolvedHide resolved
Uh oh!
There was an error while loading.Please reload this page.
src/Symfony/Component/Serializer/Mapping/Loader/XmlFileLoader.php OutdatedShow resolvedHide resolved
Uh oh!
There was an error while loading.Please reload this page.
src/Symfony/Component/Serializer/Tests/Mapping/Loader/AnnotationLoaderTest.php OutdatedShow resolvedHide resolved
Uh oh!
There was an error while loading.Please reload this page.
src/Symfony/Component/Serializer/Tests/Mapping/Loader/YamlFileLoaderTest.php OutdatedShow resolvedHide resolved
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
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.
LGTM then! 🙂
d01bf55
to83941cd
Compare(Rebased on current 6.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.
Thanks for the PR. Here are some comments to help move forward.
Uh oh!
There was an error while loading.Please reload this page.
src/Symfony/Component/Serializer/Mapping/Loader/YamlFileLoader.php OutdatedShow resolvedHide resolved
Uh oh!
There was an error while loading.Please reload this page.
src/Symfony/Component/Serializer/Mapping/Loader/YamlFileLoader.php OutdatedShow resolvedHide resolved
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
src/Symfony/Component/Serializer/Mapping/AttributeMetadataInterface.php OutdatedShow resolvedHide resolved
Uh oh!
There was an error while loading.Please reload this page.
afb3e7a
to035b0dd
Comparealamirault commentedJul 29, 2022 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
@nicolas-grekas I added layer and trigger deprecation (like urlMatcher) However, deprecation seems trigger even if methods are not called
publicfunctiontestInterface() {$attributeMetadata =newAttributeMetadata('name');$this->assertInstanceOf(AttributeMetadataInterface::class,$attributeMetadata); } |
chalasr commentedJul 30, 2022 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
Can you try documenting the param explicitly the same way as the interface? It may be enough to avoid the notice. |
Indeed, It's enough, thank you@chalasr |
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Friendly ping for re-review@nicolas-grekas |
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.
Here are some more BC notes. Please rebase also.
Uh oh!
There was an error while loading.Please reload this page.
...ymfony/Bundle/FrameworkBundle/Tests/Functional/Bundle/ModernBundle/config/serialization.yaml OutdatedShow resolvedHide resolved
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
*/ | ||
public $serializedName; | ||
public $serializedName = []; |
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.
For maximum BC, I think we should keep this as a string when possible, and use arrays only when actually required.
alamiraultOct 26, 2022 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
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.
@nicolas-grekas , Tu be sure, somthing like this ?
/*** string|array<string, string|null>*/public $serializedName;
And deal with string and array in every methods, is it right ?
* | ||
* @param string[] $groups | ||
*/ | ||
public function getSerializedName(/* array $groups = [] */): ?string |
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.
Why pass an array here? Shouldn't we accept string|null instead?
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.
Used byMetadataAwareNameConverter
https://github.com/symfony/symfony/pull/46432/files#diff-87ffe277c0213fca753a8e0b26cc8f4436e255b9776e5e08852c403df247c5b9R121
Serializer group context can be multiple. So returnedSerializerName
is the first matching group list.
Should be done inMetadataAwareNameConverter
?
Hello@alamirault, this is a great feature I was waiting for it for so long, do you you need help on this PR to resolve the latest feedbacks ? thanks |
922aabe
to03d905e
CompareIs this PR will be included in 6.2.X? or in 6.3? |
Renrhaf commentedAug 4, 2023
thank you for the contribution ! |
sigbits commentedOct 23, 2023
Will this one still be released? |
andriusvo commentedJan 8, 2024
Any plans to make it released? |
nesl247 commentedJul 16, 2024
We just ran into this need. We need to deserialize from xml we don't control, and serialize to json. Doing this any other way would be extremely complex as we're already dealing with a few hundred objects. Duplicating all of that to control it differently is not an option. |
nesl247 commentedAug 6, 2024
Would it be hard to add to |
mikevrind commentedSep 11, 2024
I really appreciate the works that people have put into this feature. Would be valuable to see this being merged in the near future because this gives us more control (and less unwanted/unexpected behaviour) within de Serializer. |
Somebody would need to pick up the work and rebase the changes onto 7.2. |
daniser commentedSep 20, 2024
Sorry guys, I completely missed this PR and discussion and created my own PR (#58236) 🤦♂️. |
Uh oh!
There was an error while loading.Please reload this page.
This PR allow to configure serialization groups for annotation
SerializedName
. Inspired by PR#37903.Before we can only define
#[SerializedName('nameOne')]
. Now, name can be different depending of groupAttributes
Annotations
YAML
XML