Order which operations are defined can result in error
API Platform version(s) affected: 2.7-beta.1
Description
Routes with placeholders such as /foo/{id} overwrite other hardcoded routes such as /foo/someText and result in a Invalid identifier value or configuration . Note that I am using ULIDs for identifiers.
Ideally, the ULID's for the /path/{id} can be matched against 26 alphanumerical characters (or something better should it exist for ULIDs). At a minimum, adding to the documentation that routes with placeholders that "could" be the same patter of a hardcoded route must be defined last (sorry if it was there and I just missed it).
How to reproduce
This works fine when using Symfony\Component\Uid\Ulid identifiers.
#[ApiResource(
operations: [
new GetCollection(
uriTemplate: '/foo/someText',
),
new Get(),
],
)]
class Foo
But changing to the following will result in a Invalid identifier value or configuration error.
#[ApiResource(
operations: [
new GetCollection(
uriTemplate: '/foo/someText',
),
new Get(),
],
)]
class Foo
{
"@context": "/contexts/Error",
"@type": "hydra:Error",
"hydra:title": "An error occurred",
"hydra:description": "Invalid identifier value or configuration.",
"trace": [
{
"namespace": "",
"short_class": "",
"class": "",
"type": "",
"function": "",
"file": "/var/www/api/vendor/api-platform/core/src/Symfony/EventListener/ReadListener.php",
"line": 97,
"args": []
},
{
"namespace": "ApiPlatform\\Symfony\\EventListener",
"short_class": "ReadListener",
"class": "ApiPlatform\\Symfony\\EventListener\\ReadListener",
"type": "->",
"function": "onKernelRequest",
"file": "/var/www/api/vendor/symfony/event-dispatcher/Debug/WrappedListener.php",
"line": 115,
"args": []
},
{
"namespace": "Symfony\\Component\\EventDispatcher\\Debug",
"short_class": "WrappedListener",
"class": "Symfony\\Component\\EventDispatcher\\Debug\\WrappedListener",
"type": "->",
"function": "__invoke",
"file": "/var/www/api/vendor/symfony/event-dispatcher/EventDispatcher.php",
"line": 230,
"args": []
},
{
"namespace": "Symfony\\Component\\EventDispatcher",
"short_class": "EventDispatcher",
"class": "Symfony\\Component\\EventDispatcher\\EventDispatcher",
"type": "->",
"function": "callListeners",
"file": "/var/www/api/vendor/symfony/event-dispatcher/EventDispatcher.php",
"line": 59,
"args": []
},
{
"namespace": "Symfony\\Component\\EventDispatcher",
"short_class": "EventDispatcher",
"class": "Symfony\\Component\\EventDispatcher\\EventDispatcher",
"type": "->",
"function": "dispatch",
"file": "/var/www/api/vendor/symfony/event-dispatcher/Debug/TraceableEventDispatcher.php",
"line": 153,
"args": []
},
{
"namespace": "Symfony\\Component\\EventDispatcher\\Debug",
"short_class": "TraceableEventDispatcher",
"class": "Symfony\\Component\\EventDispatcher\\Debug\\TraceableEventDispatcher",
"type": "->",
"function": "dispatch",
"file": "/var/www/api/vendor/symfony/http-kernel/HttpKernel.php",
"line": 128,
"args": []
},
{
"namespace": "Symfony\\Component\\HttpKernel",
"short_class": "HttpKernel",
"class": "Symfony\\Component\\HttpKernel\\HttpKernel",
"type": "->",
"function": "handleRaw",
"file": "/var/www/api/vendor/symfony/http-kernel/HttpKernel.php",
"line": 74,
"args": []
},
{
"namespace": "Symfony\\Component\\HttpKernel",
"short_class": "HttpKernel",
"class": "Symfony\\Component\\HttpKernel\\HttpKernel",
"type": "->",
"function": "handle",
"file": "/var/www/api/vendor/symfony/http-kernel/Kernel.php",
"line": 202,
"args": []
},
{
"namespace": "Symfony\\Component\\HttpKernel",
"short_class": "Kernel",
"class": "Symfony\\Component\\HttpKernel\\Kernel",
"type": "->",
"function": "handle",
"file": "/var/www/api/vendor/symfony/runtime/Runner/Symfony/HttpKernelRunner.php",
"line": 35,
"args": []
},
{
"namespace": "Symfony\\Component\\Runtime\\Runner\\Symfony",
"short_class": "HttpKernelRunner",
"class": "Symfony\\Component\\Runtime\\Runner\\Symfony\\HttpKernelRunner",
"type": "->",
"function": "run",
"file": "/var/www/api/vendor/autoload_runtime.php",
"line": 29,
"args": []
},
{
"namespace": "",
"short_class": "",
"class": "",
"type": "",
"function": "require_once",
"file": "/var/www/api/public/index.php",
"line": 5,
"args": [
[
"string",
"/var/www/api/vendor/autoload_runtime.php"
]
]
}
]
}
Possible Solution
Additional Context