Skip to content

Class property of the ApiResource annotation doesn't propagate to operations #7187

@hafkenscheid

Description

@hafkenscheid

API Platform version(s) affected: 4.1.12

Symfony version: 6.4

Description
Configuring the class property on an #[ApiResource] does not propagate to the class at the operation level.

How to reproduce
The following doesn't work:

#[ApiResource(
    class: TestEntity::class,
)]
class TestEntityApiResource
{

}

If I configure it like this, it does work:

#[ApiResource(
    operations: [
        new Post(class: TestEntity::class),
        new Get(class: TestEntity::class),
        new GetCollection(class: TestEntity::class),
        new Patch(class: TestEntity::class), 
        new Delete(class: TestEntity::class), 
    ]
)]
class TestEntityApiResource
{

}

Possible Solution
Use the class property of the resource, override it if set on the operation.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions