Skip to content

[PropertyInfo] Support using the SerializerExtractor with no group check #37040

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

Merged
merged 1 commit into from
Jun 10, 2020

Conversation

GuilhemN
Copy link
Contributor

@GuilhemN GuilhemN commented Jun 1, 2020

Q A
Branch? master
Bug fix? no
New feature? yes
Deprecations? no
Tickets
License MIT
Doc PR

It seems there is no way currently to leverage the new @Ignore annotation metadata without using serializer groups in third party code.
Indeed the only way to access the serializer's metadata is through the PropertyInfo component since metadata are marked as @internal in the Serializer component itself. However, the PropertyInfo component doesn't allow accessing them without using a groups constraint.

This PR proposes a fix by interpreting serializer_groups = null as no groups constraint.

This feature would be useful in NelmioApiDocBundle, see nelmio/NelmioApiDocBundle#1595.

Copy link
Member

@nicolas-grekas nicolas-grekas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(with a minor comment)

@fabpot fabpot force-pushed the serializerextractor branch from 589274b to 4190bfa Compare June 10, 2020 01:48
@fabpot
Copy link
Member

fabpot commented Jun 10, 2020

Thank you @GuilhemN.

@fabpot fabpot merged commit dee6d43 into symfony:master Jun 10, 2020
@GuilhemN GuilhemN deleted the serializerextractor branch June 10, 2020 05:22
@nicolas-grekas nicolas-grekas modified the milestones: next, 5.2 Oct 5, 2020
@fabpot fabpot mentioned this pull request Oct 5, 2020
nicolas-grekas added a commit that referenced this pull request Dec 10, 2020
…ties for Serializer (javer)

This PR was merged into the 5.1 branch.

Discussion
----------

[PropertyInfo][Serializer] Fixed extracting ignored properties for Serializer

| Q             | A
| ------------- | ---
| Branch?       | 5.1
| Bug fix?      | yes
| New feature?  | no
| Deprecations? | no
| Tickets       | -
| License       | MIT
| Doc PR        | -

Fixed typo in `SerializerExtractor::getProperties()` introduced in 8526d7c which leads to the error after #37040.
`$serializerClassMetadata` is instance of `Symfony\Component\Serializer\Mapping\ClassMetadata`, which doesn't contain `isIgnored` method, this methods is located in `Symfony\Component\Serializer\Mapping\AttributeMetadata` which is `$serializerAttributeMetadata` here. More over, it doesn't make sense to check the method existence in one class and call it for another.

Commits
-------

594ce46 [PropertyInfo][Serializer] Fixed extracting ignored properties
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants