-
-
Notifications
You must be signed in to change notification settings - Fork 5.2k
[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
[Serializer] documentation for allow_extra_attributes #6975
Conversation
f4400f3
to
e6818fc
Compare
components/serializer.rst
Outdated
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, |
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.
This will throw an [...]
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.
done
components/serializer.rst
Outdated
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``:: |
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.
[...] because city is not an attribute of the Person
class
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.
done
components/serializer.rst
Outdated
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``. |
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.
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 tofalse
to let the serializer throw an exception when additional attributes are passed.
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.
done
e6818fc
to
8318e14
Compare
8318e14
to
28dcc94
Compare
@xabbuh thanks for your review |
… 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
… 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
The code PR has been merged. |
👍 (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) |
Thank you @juliendidier. |
…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
Doc PR for symfony/symfony#19958