dedoc / scramble

Modern Laravel OpenAPI (Swagger) documentation generator. No PHPDoc annotations required.
https://scramble.dedoc.co/
MIT License
979 stars 87 forks source link

Route with optional parameter doesn't work #249

Closed baradhili closed 4 months ago

baradhili commented 9 months ago

On Laravel 10 current with scramble v0.8.4 I have a route:

Route::any('db/proxy/{path?}', [CouchDBProxyController::class, 'handle'])
            ->where('path', '.*');

Which displays in Scramble as "http://laravel-api.test/api/v1/db/proxy/{path?}"

But which fails in the test form and the curl code shows as:

curl --request GET \
  --url 'http://laravel-api.test/api/v1/db/proxy/%7Bpath?%7D=' \
  --header 'Accept: application/json' \
  --header 'Authorization: Bearer 1|laravel_sanctum_1bWbhuJkFHTSvqetlVoQCGTFJn03yx22WeGnA7gZ99324d36'

The issue is that the encoded "{path?}" is turning up in the URL instead of being replaced by the variable

baradhili commented 9 months ago

Might be related: When I have a route with a mandatory parameter with constraints like:

Route::get('auth/{provider}', [AuthController::class, 'redirectToProvider'])
            ->where('provider', 'azure|github');

The curl shows up as

curl --request GET \
  --url http://laravel-api.test/api/v1/auth/provider \
  --header 'Accept: application/json' \
  --header 'Authorization: Bearer 1|laravel_sanctum_1bWbhuJkFHTSvqetlVoQCGTFJn03yx22WeGnA7gZ99324d36'

Note this time the "{}" are not rendered, but the parameter is still there in the url

romalytvynenko commented 4 months ago

Duplicate of #100