Symfony : Api-platform and cascading DTos

  api, dto, symfony

I have an Api-platform project in which I use DTO.
I have Foo entity which is an API ressource with :

 * @ApiResource(
 *   input=FooInput::class,
 *   attributes={
 * ...
 *   }
 * )
 * @ORMEntity(repositoryClass="AppRepositoryFooClasseRepository")
class Foo
     * @ORMId()
     * @ORMGeneratedValue()
     * @ORMColumn(type="integer")
    private $id;

     * @ORMColumn(type="string", length=50)
    private $label;
     * @ORMOneToMany(targetEntity="AppEntityBar", mappedBy="bar", orphanRemoval=true, cascade="all")
    private $bars;

and the DTO:

final class FooInput {
     * @var integer
    public $id;
     * @var string
     * @AssertNotBlank()
    public $label;
    public $bars;  

As you can see, there is also a Bar entity, which may not be accessed via the API (no /api/bars endpoint) and which has a OneToMany relation with the Foo entity.

I would like to use a dedicated DTO for the Bar entity.
I then created the /App/Dto/BarInput.php, but I do not know where/how to define "input=BarInput::class"

If I add @ApiRessource in Bar, this will create a Bar endpoint which I do not want…

Thank you for your help!

Source: Symfony Questions