You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi,
I have trouble deserializing a datetime object from request body.
I added birthDate field to CreateUserReqDto. Should I deserialize it manually?
In a documentation I found that DTOs should inherit Apitte\Core\Mapping\Request\BasicEntity and presumably override normalize method (which is not mentioned in the documentation). But it doesn't work.
I guess the same problem is going to be with other non-primitive types.
The text was updated successfully, but these errors were encountered:
Solution is to use typed properties (and fix typos I made during example creation).
However, new bug appears: when I try to use typed property for nullable attribute Typed property App\Domain\Api\Request\CreateUserReqDto::$password must not be accessed before initialization caused by JsonDispatcher.
And the question about inheritance and normalize method remains.
Now the normalize method would be useful. I could hide \Nette\Utils\Arrays::toObject there. And some sort of validation would be nice.
I guess the only way to do it automatically would be using some sort of annotation at the attribute since arrays in PHP have no type constraints.This is enough for OpenApi definition generator so it could be used for deserialization.
Edit: \Nette\Utils\Arrays::toObject is not enough. It does not deserialize DateTime :(
Hi,
I have trouble deserializing a datetime object from request body.
I added birthDate field to
CreateUserReqDto
. Should I deserialize it manually?In a documentation I found that DTOs should inherit
Apitte\Core\Mapping\Request\BasicEntity
and presumably overridenormalize
method (which is not mentioned in the documentation). But it doesn't work.I guess the same problem is going to be with other non-primitive types.
The text was updated successfully, but these errors were encountered: