Open
Description
API Platform version(s) affected: 4.1.5
Description
Say I have a resource that uses GET, PUT, and PATCH methods. This resource is also used as a property of another resource, using the POST method and different serialization groups. If I mark the PUT method as deprecated (because I prefer PATCH instead) then it gets marked as deprecated in the other resource and is missing from the Swagger documentation, even though it continues to work as expected.
How to reproduce
Class User
:
#[ApiResource(
normalizationContext: ['groups' => ['read']],
denormalizationContext: ['groups' => ['update']],
)]
#[Get]
#[GetCollection]
#[Put(
deprecationReason: 'Use PATCH instead',
)]
#[Patch]
class User
{
#[Groups(['read', 'custom_read'])]
private string $username;
#[Groups(['custom_update', 'custom_read'])]
private string $foo;
public function getUsername(): string
{
return $this->username;
}
public function setUsername(string $username): User
{
$this->username = $username;
return $this;
}
public function getFoo(): string
{
return $this->foo;
}
public function setFoo(string $foo): User
{
$this->foo = $foo;
return $this;
}
}
Class CustomUserAction
:
#[ApiResource(
operations: [
new Post(),
],
normalizationContext: ['groups' => ['custom_read']],
denormalizationContext: ['groups' => ['custom_update']],
)]
class CustomUserAction
{
#[Groups(['custom_update', 'custom_read'])]
#[ApiProperty(required: true)]
private User $user;
public function getUser(): User
{
return $this->user;
}
public function setUser(User $user): CustomUserAction
{
$this->user = $user;
return $this;
}
}
Additional Context
If the PUT method is not deprecated, or not available at all, everything looks good:
If the PUT method exists and is deprecated, this happens:
Am I doing something wrong or is this a bug?
Thanks