Fix denormalization of basic property-types in XML and CSV#3191
Fix denormalization of basic property-types in XML and CSV#3191warslett wants to merge 2 commits into
Conversation
4a49ff9 to
8ce220e
Compare
8ce220e to
ff18160
Compare
|
This is not the correct approach. The type cast feature should be added to Symfony Serializer. It should be controlled by a flag in the context. |
|
@teohhanhui that was my initial thinking aswell. The problem is that the AbstractObjectNormalizer handles this behaviour in the Serializer component and is extended by AbstractItemNormalizer in the API Platform. AbstractObjectNormalizer resolves types using an optional dependency called PropertyTypeExtractor but AbstractItemNormalizer overrides the constructor of AbstractObjectNormalizer and does not inject this dependency. Instead, AbstractItemNormalizer has a dependency on a different service PropertyMetadataFactory which can be used to determine types. This means that AbstractItemNormalizer used with API Platform has a completely different mechanism for resolving types than AbstractObjectNormalizer when used with vanilla Serializer component. Therefor this problem needs to be solved separately in the Serializer component and the API Platform. This is not ideal but is due to the way inheritance has been used. |
|
Yes, I get what you mean, but I think we should fix this in Symfony first. Then we can see how we'll fix it in API Platform. (Probably by calling the same methods from Symfony Serializer.) |
|
Superseded by #4145. |
|
Thank you @warslett. |
This PR fixes an issue where by posting XML content throws errors when a field has a non string primitive type because the XML encoder can only normalize primitive values as strings. This means that post create and update requests fail. This PR adds some additional behaviour where by the AbstractItemNormalizer will cast valid strings as the correct type.