Skip to content

[Metadata] #[Get] provider doesn't give $uriVariables as of 4.2.0 #7394

@stephanvierkant

Description

@stephanvierkant

I've a Enum as an ApiResource, based on this blog post:

#[Get(routePrefix: '/foobar', provider: FooBarStatus::class . '::getCase'),]
enum FooBarStatus : string
{
    /** @param array<string, mixed> $uriVariables */
    public static function getCase(Operation $operation, array $uriVariables) : static
    {
        $name = $uriVariables['id'] ?? null;

        $reflectionClass = new ReflectionEnum($operation->getClass());

        if ($reflectionClass->getBackingType()->getName() === 'int') {
            $name = (int) $name;
        }

        return self::tryFrom($name);
    }
}

In endpoint /api/foobar/foo_bar_status/concept $uriVariables returned
array:1 [▼
"id" => "concept"
]
in 4.1.24, but
array:1 [▼
"id" => 0
]
in 4.2.0.

Can someone explain what should be changed? I've upgraded the api-platform/metadata package to v4.2.0-beta.1 and that's where the issue started.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions