Skip to content

Route with custom uriTemplate stopped working after upgrade to 3.0.5 #5234

@acirulis

Description

@acirulis

API Platform version(s) affected: 3.0.5 - 3.0.6

Description
I have a resource with following config:

#[ApiResource(
    shortName: 'Inventory',
    operations: [
        new GetCollection(
            uriTemplate: '/warehouses/{warehouseId}/inventory',
        ),
        new Get(
            uriTemplate: '/warehouses/{warehouseId}/inventory/{id}',
        ),
    ],
    uriVariables: [
        'warehouseId' => new Link(
            fromProperty: 'id',
            fromClass: WarehouseResource::class,
        )
    ],
    normalizationContext: ['groups' => ['inventory:read']],
    denormalizationContext: ['groups' => ['inventory:write']],
    provider: InventoryResourceProvider::class,
)]
...

After upgrade to v3.0.5, GetCollection endpoint dies with error ( "Unable to generate an IRI for the item of type "App\ApiResource\InventoryResource"",)

Stack:

"Symfony\Component\Routing\Exception\MissingMandatoryParametersException: Some mandatory parameters are missing ("id") to generate a URL for route "_api_/warehouses/{warehouseId}/inventory/{id}_get". in /var/www/html/api/vendor/symfony/routing/Generator/UrlGenerator.php:175
Stack trace:
#0 /var/www/html/api/vendor/symfony/routing/Generator/CompiledUrlGenerator.php(67): Symfony\Component\Routing\Generator\UrlGenerator->doGenerate(Array, Array, Array, Array, Array, '_api_/warehouse...', 1, Array, Array)
#1 /var/www/html/api/vendor/symfony/routing/Router.php(225): Symfony\Component\Routing\Generator\CompiledUrlGenerator->generate('_api_/warehouse...', Array, 1)
#2 /var/www/html/api/vendor/api-platform/core/src/Symfony/Routing/Router.php(102): Symfony\Component\Routing\Router->generate('_api_/warehouse...', Array, 1)
#3 /var/www/html/api/vendor/api-platform/core/src/Symfony/Routing/IriConverter.php(187): ApiPlatform\Symfony\Routing\Router->generate('_api_/warehouse...', Array, 1)
#4 /var/www/html/api/vendor/api-pl"

Additional Context
Worked before 3.0.5

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