Reputation: 21
Using the v3 of Api Platform, I'm encountering the following problems when working with DTO:
I've tried different solutions and digged in into the source code before asking, and i don't find any way to solve these two problems.
Upvotes: 1
Views: 1644
Reputation: 46
You now have to set your GET operation on the DTO in order to have the @id field correctly generated, see this issue for reference.
So if you have this entity:
<?php
#[Get(
output: MyEntityDTO::class,
provider: MyEntityProvider::class
)]
class MyEntity {
private int $id;
}
You'll have this DTO:
<?php
#[Get(shortName: 'MyEntity')]
class MyEntityDTO {
public int $id;
}
Note that you have to set the shortName to allow having all your operation under the same MyEntity tag in the swagger documentation.
For your second question, you now have to use Providers and Processors to handle the state of your data in api-platform v3, see the documentation. In the case of a PUT/PATCH operation, you'll have to use a processor.
Upvotes: 1