Thanks to visit codestin.com
Credit goes to github.com

Skip to content

[Serializer] documentation for allow_extra_attributes #6975

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
Mar 3, 2017

Conversation

juliendidier
Copy link
Contributor

@juliendidier juliendidier force-pushed the serializer-extra-attributes branch from f4400f3 to e6818fc Compare September 18, 2016 10:49
@weaverryan weaverryan changed the title [Serializer] documentation for allow_extra_attributes [WCM][Serializer] documentation for allow_extra_attributes Sep 19, 2016
has a fourth parameter, the context. If you want to throw an exception if an attribute is outside
the object scope, use ``allow_extra_attributes`` as ``false``.

This will throws a :class:`Symfony\\Component\\Serializer\\Exception\\ExtraAttributesException` exception,
Copy link
Member

Choose a reason for hiding this comment

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

This will throw an [...]

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

the object scope, use ``allow_extra_attributes`` as ``false``.

This will throws a :class:`Symfony\\Component\\Serializer\\Exception\\ExtraAttributesException` exception,
because city is not an attribute of ``Acme\Person``::
Copy link
Member

Choose a reason for hiding this comment

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

[...] because city is not an attribute of the Person class

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

by the serializer.
:method:`Symfony\\Component\\Serializer\\Serializer::deserialize`
has a fourth parameter, the context. If you want to throw an exception if an attribute is outside
the object scope, use ``allow_extra_attributes`` as ``false``.
Copy link
Member

Choose a reason for hiding this comment

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

I would reword this a bit:

By default, additional attributes that are not mapped to the denormalized object will be ignored by the Serializer component. Set the allow_extra_attributes key of the deserialization context to false to let the serializer throw an exception when additional attributes are passed.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

@juliendidier
Copy link
Contributor Author

@xabbuh thanks for your review

@xabbuh xabbuh added this to the 3.3 milestone Nov 12, 2016
symfony-splitter pushed a commit to symfony/serializer that referenced this pull request Dec 5, 2016
… used during an object denor… (juliendidier)

This PR was merged into the 3.3-dev branch.

Discussion
----------

[Serializer] Throw exception when extra attributes are used during an object denor…

| Q | A |
| --- | --- |
| Branch? | "master" |
| Bug fix? | no |
| New feature? | yes |
| BC breaks? | no |
| Deprecations? | no |
| Tests pass? | yes |
| Fixed tickets | #19948 |
| License | MIT |
| Doc PR | [#6975](symfony/symfony-docs#6975) |

I will update the doc if you're ok with this PR.

Commits
-------

565a984 throw exception when extra attributes are used during an object denormalization
dunglas added a commit to symfony/symfony that referenced this pull request Dec 5, 2016
… used during an object denor… (juliendidier)

This PR was merged into the 3.3-dev branch.

Discussion
----------

[Serializer] Throw exception when extra attributes are used during an object denor…

| Q | A |
| --- | --- |
| Branch? | "master" |
| Bug fix? | no |
| New feature? | yes |
| BC breaks? | no |
| Deprecations? | no |
| Tests pass? | yes |
| Fixed tickets | #19948 |
| License | MIT |
| Doc PR | [#6975](symfony/symfony-docs#6975) |

I will update the doc if you're ok with this PR.

Commits
-------

565a984 throw exception when extra attributes are used during an object denormalization
@xabbuh xabbuh removed the On hold label Dec 6, 2016
@xabbuh
Copy link
Member

xabbuh commented Dec 6, 2016

The code PR has been merged.

@wouterj
Copy link
Member

wouterj commented Dec 17, 2016

👍
status: reviewed

(there is a minor issue with the line length and the second paragraph can maybe replaced by a code comment in de code itself, but those things can be fixed during the merge)

@javiereguiluz javiereguiluz changed the title [WCM][Serializer] documentation for allow_extra_attributes [Serializer] documentation for allow_extra_attributes Dec 23, 2016
@xabbuh xabbuh changed the base branch from master to 3.2 March 3, 2017 07:46
@xabbuh xabbuh changed the base branch from 3.2 to master March 3, 2017 07:47
@xabbuh
Copy link
Member

xabbuh commented Mar 3, 2017

Thank you @juliendidier.

@xabbuh xabbuh merged commit 28dcc94 into symfony:master Mar 3, 2017
xabbuh added a commit that referenced this pull request Mar 3, 2017
…juliendidier)

This PR was merged into the master branch.

Discussion
----------

[Serializer] documentation for allow_extra_attributes

Doc PR for [symfony/symfony#19958](symfony/symfony#19958)

Commits
-------

28dcc94 [Serializer] documentation for allow_extra_attributes
xabbuh added a commit that referenced this pull request Mar 3, 2017
@juliendidier juliendidier deleted the serializer-extra-attributes branch March 7, 2017 09:26
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.

6 participants