dedoc / scramble

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

Scramble fails to understand different responses via same method #520

Closed benascbr closed 2 months ago

benascbr commented 2 months ago

I've tried to create pull request for this example but failed due permissions. https://github.com/dedoc/demo-scramble/tree/main

To reproduce please change: BookingsController

    public function index(Request $request)
    {
        return $this->response(['foo1' => 'bar1'], 200);
    }

    public function indexFoo()
    {
        return $this->response(['foo2' => 'bar2'], 200);
    }

    public function response($collection, $code)//simplified example
    {
        return response()->json([
            'code'   => $code,
            'status' => 'OK',
            'data'   => $collection,
        ], $code);
    }

routes/api.php

    Route::apiResource('bookings', BookingsController::class);
    Route::get('/bookings/foo', [BookingsController::class, 'indexFoo']);

Actual: http://scramble.test/docs/api#/operations/bookings.index shows response.data.foo1 http://scramble.test/docs/api#/operations/bookings.indexFoo shows response.data.foo1

Expected: http://scramble.test/docs/api#/operations/bookings.index shows response.data.foo1 http://scramble.test/docs/api#/operations/bookings.indexFoo shows response.data.foo2

benascbr commented 2 months ago

image image

romalytvynenko commented 2 months ago

@benascbr fixed in 0.11.13

Thanks for reporting! Indeed a nasty bug

benascbr commented 2 months ago

@romalytvynenko thank you very much for such prompt help :tada: and this package!