Skip to content

Fixes ignoring type checks during denormalization #1957

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 2 commits into from
Feb 26, 2019
Merged

Fixes ignoring type checks during denormalization #1957

merged 2 commits into from
Feb 26, 2019

Conversation

IckleChris
Copy link
Contributor

Q A
Bug fix? yes
New feature? no
BC breaks? no
Deprecations? no
Tests pass? yes
Fixed tickets n/a
License MIT
Doc PR n/a (already explained)

This PR updates the denormalization process to honour the ObjectNormalizer::DISABLE_TYPE_ENFORCEMENT flag, allowing invalid types to be handled by the validation layer instead of endpoints returning (by default) 500 status serialization errors.

@@ -201,7 +201,10 @@ protected function setAttributeValue($object, $attribute, $value, $format = null
return;
}

$this->validateType($attribute, $type, $value, $format);
if (empty($context[AbstractObjectNormalizer::DISABLE_TYPE_ENFORCEMENT])) {
Copy link
Contributor Author

@IckleChris IckleChris May 19, 2018

Choose a reason for hiding this comment

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

Looks like the usage of the constant from the Serializer is causing failing tests, should the constant be defined anew within this class (despite the duplication)?

…DISABLE_TYPE_ENFORCEMENT flag during denormalization
@soyuka soyuka changed the base branch from 2.2 to 2.4 February 26, 2019 10:26
@soyuka soyuka merged commit ea5bc7c into api-platform:2.4 Feb 26, 2019
@soyuka
Copy link
Member

soyuka commented Feb 26, 2019

Thanks @IckleChris !

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.

3 participants