Comments (5)
Had the same problem. Try adding requirements to the first Get() operation.
For example if your IDs are in the UUID format add:
requirements: ['id' => '[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}']
Then the 'invoice' part of the url won't be treated as the {id} in that first GET operation.
If you want to apply the same requirement to every operation you can do something like that:
<?php
namespace App\Service;
use Symfony\Component\Config\Loader\Loader;
class RouteRequirementEnforceLoader extends Loader
{
private $decorated;
public function __construct(Loader $decorated, ?string $env = null)
{
parent::__construct($env);
$this->decorated = $decorated;
}
public function load($resource, string $type = null)
{
$routes = $this->decorated->load($resource, $type);
foreach ($routes as $route) {
$route->setRequirement('id', '[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}');
}
return $routes;
}
public function supports($resource, string $type = null)
{
return $this->decorated->supports($resource, $type);
}
}
and then add that to the services:
services:
App\Service\RouteRequirementEnforceLoader:
decorates: 'routing.loader'
arguments: [ '@App\Service\RouteRequirementEnforceLoader.inner' ]
from api-platform.
Re-posted here: api-platform/core#6148. Unfortunately this is quite critical for us, as we want to avoid breaking changes as far as possible. Is there any chance that someone will take care of this problem? Or should we use commercial support?
from api-platform.
Hello. I have spent already like 3 days looking for some solutions to my problem and I think it is related with this issue.
I started a new project and I am using API Platform 3.2 too and PHP 8.2 but instead of getting an 404 error, I am getting an 405 error. This one in particular:
{"class":"Symfony\\Component\\HttpKernel\\Exception\\MethodNotAllowedHttpException","code":405,"message":"No route found for \"POST http://localhost:250/api/v1/users/register\": Method Not Allowed (Allow: GET, PUT, PATCH, DELETE)"}
This endpoint is for user register.
I am not using attributes directly in my PHP code, but I am using .yaml files instead. This my User.yaml file resources:
App\Entity\User:
attributes:
normalization_context:
groups: [user_read]
collectionOperations:
# User register
register:
method: POST
path: /users/register
controller: App\Controller\Action\User\Register
denormalization_context:
groups: [user_register]
openapi_context:
summary: Register a new user
itemOperations:
get:
method: GET
My question is if this issues is related, if not, I will open a new issue.
Thanks.
EDIT
I tried to downgrade to a previous version (3.0 and 3.1) but the problem is still there.
from api-platform.
If you move the get collection before the get it should fix it.
from api-platform.
duplicate
from api-platform.
Related Issues (20)
- Subresource Identifier
- Validation of path parameters HOT 1
- http instead https docs.jsonld
- Use of property class on APIResource Tag
- Custom Controller via POST accessible, not via GET-Collection
- UniqueEntity not fully working on PUT HOT 4
- Error "Unable to generate an IRI" if id has "." or ":"
- what is the best way to add current user information related to GetCollection request HOT 5
- SwaggerUI shows error: Unable to render this definition HOT 1
- Redundant @context field in OpenAPI for embedded JSON+LD resources
- denormalizationContext imbrique
- New Format : RSS feed
- Open up Paginator::$documents for read
- 502 status code in "Check PWA reachability" ci step
- Specific order of operations in #ApiResource annotation causes incorrect API schema (using wrong serialization group)
- Impossible to use vite/vue3 with supplied Caddyfile HOT 3
- The event_listeners_backward_compatibility_layer: true is broken in version 3.3.0 HOT 1
- Building 3.3.2 for production throws: Error: <Html> should not be imported outside of pages/_document. HOT 3
- "Invalid identifier value or configuration." HOT 1
- ProcessorInterface multiple ProcessorInterfaces (persist & remove) && Security within State Providers
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from api-platform.