question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Custom subresource path doesn't work

See original GitHub issue

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
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"="/BLABLABLA/organizations/{organization_id}/users",
 *              "requirements"={"organization_id": StringHelper::UUIDv4Regex},
 *              "security"="is_granted('readOrganization', organization_id)"
 *          }
 *      }

I can put this annotation in the User or the Organization entity, I have the same result.

The security works but not the rest.

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

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:6

github_iconTop GitHub Comments

13reactions
plfortcommented, Jul 22, 2020

Try with “users_get_subresource” as operation name (instead of “api_organizations_users_get_subresource”). https://github.com/api-platform/docs/issues/1109

This PR was merge https://github.com/api-platform/docs/pull/370 but this commit revert the changes https://github.com/api-platform/docs/commit/b8304bc4a32ac16d6e71997a8b0682187caaa473

2reactions
bastounecommented, Jul 28, 2020

Thanks, I won’t use this feature since it seems not to be stable. Maybe the doc shall be changed ?

Read more comments on GitHub >

github_iconTop Results From Across the Web

API Platform - Custom subresource path doesn't work
I try to override the path (and security, and requirements) of a subresource. It works for the security, but not for path (and...
Read more >
PHP Symfony API Platform custom subresource ... - YouTube
In this video I'll be working with Symfony and the API Platform package ... PHP Symfony API Platform custom subresource path by overriding ......
Read more >
Subresources - API Platform
A Subresource is another way of declaring a resource that usually involves a more complex URI. In API Platform you can declare as...
Read more >
Subresources and Runtime Resource Resolution - The Java ...
A root resource can then implement subresources that can process the remainder of the URI path. A resource class method that is annotated...
Read more >
4. Using Custom Resources - Programming Kubernetes [Book]
Pods have a number of subresources, such as /logs, /portforward, /exec, and /status. The corresponding subresource HTTP paths are: /api/v1/namespace/ namespace ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found