[Bug]: Routes matching multiple HTTP methods are not properly supported
What happened?
If a route is available on multiple HTTP methods (eg: it's common for PUT & PATCH), only the first HTTP method is displayed in the doc.
How to reproduce the bug
Create a new route to match multiple HTTP methods:
// This will result in a doc page only for PUT:
Route::match(['put', 'patch'], '/customers/{customer}', [CustomerController::class, 'update']);
// This will result in a doc page only for PATCH:
Route::match(['patch', 'put'], '/customers/{customer}', [CustomerController::class, 'update']);
Package Version
0.12.19
PHP Version
8.2
Laravel Version
12
Which operating systems does with happen with?
No response
Notes
This issue also affects apiResource(), PATCH is missing in the doc because I guess Route::match(['put', 'patch'], ...) is used under the hood:
Route::apiResource('customers', CustomerController::class);
But if you check with php artisan route:list, we can find that PUT & PATCH are available:
@Seb33300 what is the expected documentation result here?
If I do:
Route::put('/customers/{customer}', [CustomerController::class, 'update']);
Route::patch('/customers/{customer}', [CustomerController::class, 'update']);
The result is correct:
Previous result is also what I expect when I do:
Route::match(['put', 'patch'], '/customers/{customer}', [CustomerController::class, 'update']);
But currently, I can see only PUT:
@Seb33300 but wouldn't it be a bummer to get both PUT and PATCH in case of using apiResource? I know that indeed the endpoint is available on both verbs. But seems like the documentation would be too verbose.
Also what about that GET|HEAD endpoints? Do you also expect to get HEAD part documented too?
Also what about that GET|HEAD endpoints? Do you also expect to get HEAD part documented too?
I want to say "yes", because if that endpoint exists, it may be useful for someone, so I may want to add it in my documentation. But I also understand that it may be annoying in most cases.
Maybe a new config option could be introduced to hide the HTTP methods we do not want show in the documentation?
In my case, I would prefer to show PATCH instead of PUT, because if we strictly follow how REST APIs are meant to work, a PUT endpoint is intended to replace a resource, while PATCH allows partial updates.
And PATCH is how most Laravel API are working.
For example, with API Platform, PATCH is enabled by default and PUT is not: https://api-platform.com/docs/core/operations/