[Laravel] Missing Get() operation in Swagger UI with explicit REST actions
API Platform version(s) affected: 4.0.4
Description
When I use the explicit declaration of the REST action for my model, the 'Get' action (api/categories/{id}) doesn't appear in the Swagger UI or in the route list when I run 'php artisan route:list'.
Also, as you can see in the screenshots, the description of the call is 'Retrieves a Category resource' instead of 'Retrieves a Collection of Category resources'.
Note : The only model that work normaly is "User", i don't know why.
How to reproduce
- Create a new project with Laravel 11
- Add API Platform
- Create a model and explicitly add the REST actions as follows:
#[ApiResource(
operations: [
new GetCollection(),
new Get()
]
)]
- Go to your API documentation. You'll notice that only GetCollection() is visible, while Get() is missing.
Possible Solution
Additional Context
After further investigation, this is not actually a bug, but rather appears to be a documentation gap. If we don't have a database table associated with the model, API Platform does not recognize it as a valid model.
The model description in the schema is not available. Therefore, migrations need to be run first.