fix(object-mapper): on creation, give expected class to object mapper#7795
fix(object-mapper): on creation, give expected class to object mapper#7795Cafeine42 wants to merge 1 commit intoapi-platform:mainfrom
Conversation
|
28834e6 should fix some of the input/output issues can you check if you're using the 4.3 version? |
Interesting use case we may need a new security layer in there. Could you provide a functional test case?
IIRC a recent patch has been merged for this as there was a bug with the UniqueEntity constraint. Let me know if you struggle with that. |
|
I made the PR for 4.3 #7796 with the minimal change in tests.
I just tested with the main branch and it works fine for my project. From what I understand, the validator runs first on the DTO / ApiResource, then on the mapped object. So validation happens at both levels. Since it runs in two sequential steps, a validation error on the mapped object won’t be returned if a validation error already occurred on the input DTO. The calls are executed one after the other. In the future, there might be a need to collect and return all validation errors so we can surface issues from both the DTO and the mapped object. That said, the current behavior works perfectly fine for my project.
I’m starting to work on this topic. |
|
|
|
I initially tried applying the project's legacy voters, but after reviewing it, that approach doesn’t make sense in this specific case. So this part is fine for me, just need the target class on map call. |

When the input DTO or the API resource has multiple mapping targets, during a POST request with ApiPlatform, provide the expected target to the objectMapper to ensure the correct mapping is used.