Reputation:
I have an entity and a DTO that I would like to use in POST requests. Here are my two classes.
<?php
declare(strict_types=1);
namespace App\Entity;
use ApiPlatform\Core\Annotation\ApiResource;
use App\Dto\TestPost;
/**
* @ApiResource(
* collectionOperations={
* "post"={
* "input"=TestPost::class
* }
* },
* itemOperations={}
* )
*/
final class Test
{
public string $foo;
public string $bar;
}
<?php
declare(strict_types=1);
namespace App\Dto;
final class TestPost
{
/**
* @var string
*/
public string $xxx;
}
I expected that in the Swagger documentation the field "xxx" would be shown. Instead the two fields "foo" and "bar" of the original entity are shown. Have I forgotten something?
Upvotes: 1
Views: 812
Reputation:
It seems like I have to define the output, too. It works when I add an "output" key like so:
<?php
declare(strict_types=1);
namespace App\Entity;
use ApiPlatform\Core\Annotation\ApiResource;
use App\Dto\TestPost;
/**
* @ApiResource(
* collectionOperations={
* "post"={
* "input"=TestPost::class,
* "output"=false
* }
* },
* itemOperations={}
* )
*/
final class Test
{
public string $foo;
public string $bar;
}
Upvotes: 1