BastienSander
BastienSander

Reputation: 1838

API Platform - Custom subresource path doesn't work

API Platform version(s) affected: 2.5.6

Description
Following this documentation: https://api-platform.com/docs/core/subresources/#using-custom-paths

I try to override the path (and security, and requirements) of a subresource.

It works for the security, but not for path (and so requirements).

How to reproduce
Clone this repo and follow the very small README : https://github.com/bastoune/api-platform-issue-1581

Having this route with debug:router : api_organizations_users_get_subresource GET ANY ANY /v2/organizations/{id}/users.{_format} and this annotation :

 *      subresourceOperations={
 *          "api_organizations_users_get_subresource"={
 *              "method"="GET",
 *              "path"="/TEEEST/organizations/{organization_id}/users",
 *              "requirements"={"organization_id": StringHelper::UUIDv4Regex},
 *              "security"="is_granted('readOrganization', organization_id)"
 *          }
 *      }

The security works but not the rest.

If I remove the security, it doesn't work anyway.

Upvotes: 1

Views: 2351

Answers (1)

BastienSander
BastienSander

Reputation: 1838

As mentioned here : https://github.com/api-platform/api-platform/issues/1581#issuecomment-662503549

There is a bug with the operation name:

Try with "users_get_subresource" as operation name (instead of "api_organizations_users_get_subresource"). api-platform/docs#1109

This PR was merge api-platform/docs#370 but this commit revert the changes api-platform/docs@b8304bc

Upvotes: 6

Related Questions