Skip to content

Deprecating the PUT method seems to have unintended side effects #7064

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
pauljura opened this issue Apr 4, 2025 · 1 comment
Open

Deprecating the PUT method seems to have unintended side effects #7064

pauljura opened this issue Apr 4, 2025 · 1 comment
Labels

Comments

@pauljura
Copy link

pauljura commented Apr 4, 2025

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:

Image

Image

If the PUT method exists and is deprecated, this happens:

Image

Image

Am I doing something wrong or is this a bug?

Thanks

@soyuka soyuka added the bug label Apr 7, 2025
@soyuka
Copy link
Member

soyuka commented Apr 7, 2025

maybe that #6960 can also fix this

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants