mtrajano / laravel-swagger

Auto generates the swagger documentation of a laravel project based on best practices and simple assumptions
167 stars 71 forks source link

SuccessResponseGenerator is missing methods #41

Open trinvh opened 4 years ago

trinvh commented 4 years ago

Description:

If there is a route with PATCH method an error will be thrown: Undefined index: patch

Fixed it in SuccessResponseGenerator.php:

$methodMappingHttpCode = [
            'head' => 200,
            'get' => 200,
            'post' => 201,
            'put' => 204,
            'delete' => 204,
            'patch' => 204,
        ];

Another issue when I'm using laravel-debugbar in src/DataObjects/Route.php line #78 since middleware constructor only accept string, so I had to hack it like this

protected function formatMiddleware()
    {
        return array_map(function ($middleware) {
            if (gettype($middleware) !== 'string') {
                // dd($middleware);
                return new Middleware('ignored');
            }
            return new Middleware((string)$middleware);
        }, $this->route->gatherMiddleware());
    }

Tried to dump the $middleware object then I got:

^ Closure($request, $next)^ {#1346
  class: "Barryvdh\Debugbar\Controllers\BaseController"
  this: Barryvdh\Debugbar\Controllers\OpenHandlerController {#1345 …}
}

Another issue again: Is this package dependant to laravel-passport? Tried to disable parseSecurity to false but it was still required. I had to install laravel-passport and configure it to make this package working

mtrajano commented 4 years ago

Hey thank you for submitting this issue I'll look into this tonight. laravel-passport is only required for local development (testing) when installing the package make sure to pass the --no-dev flag in order not to pull any dev packages (phpunit, laravel-passport, etc.). If the package is breaking because you're missing laravel-passport (with the parseSecurity) option set to false than that is a bug and I'll look into it as well.

mtrajano commented 4 years ago

@trinvh I pushed a fix for the missing methods in the v0.7.x-dev branch, sorry about that. I will look into parseSecurity issue tomorrow, thanks for reporting!

trinvh commented 4 years ago

Great work @mtrajano . Thank you!