POST result isn't auto-wired to Output DTO #7640
Replies: 1 comment
-
|
So I finally found a solution! By re-implementing my standard-processor and add |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Underneath my setup (in short, without use statements and getters and setters); symfony 8.0 (ObjectMapper 8.0) and ApiPlatform 4.2.
REPO: https://github.com/arthurGrinjo/ApiPlatformDtoPostPutFailure
Basically it's about this description: https://api-platform.com/docs/core/dto/#2-automated-mapped-inputs-and-outputs
Get()andGetCollection()work perfectly fine with my dto structure. The Post operation does add an object to the DB however the result is a 400 error: "Unable to generate an IRI for the item of type "App\Dto\Route"" Which seems to be logic, in this class I describe the operations. However it's not the output class defined in the Post operation which is actually mapped to the correct source.Debugging shows me the code does understand there is an output dto. However the class property in the Operation is set to
app/dto/route.Adding
class: RouteEntity.phpto the Post-operation does have some effect; no 400 error, and a response with"@id": "/api/.well-known/genid/de884912fcb9bca17e56",but now it bypasses the dto's and its validation.Adding an
#[Map()]toApp\Dto\Route.phpwith target and/or resource has no effect and does not seem to be logic.Using a custom processor has no effect. The class is already defined in the Operation and results in the same 400-error.
How to tell my application to use the output dto in combination with the route-entity? Before this symfony version and api platform version I used self-written processors, providers and mappers, also for the Get operations. With the latest version of the ObjectMapper and ApiPlatform I could already remove the mappers and providers for the get operations. I hope this is also possible for Post and Put operations.
LATEST VERSION SEE: REPO
Entity Route.php
ApiResource Route.php
Request DTO RouteRequestDto.php
Beta Was this translation helpful? Give feedback.
All reactions