Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Doc generation fails if resource controller is partial #426

Closed
phanan opened this issue Dec 8, 2018 · 1 comment · Fixed by #429
Closed

Doc generation fails if resource controller is partial #426

phanan opened this issue Dec 8, 2018 · 1 comment · Fixed by #429

Comments

@phanan
Copy link
Contributor

phanan commented Dec 8, 2018

Version 3.1.1

It seems the package assumes a resource controller has all RESTful methods. For example if I have a controller like this:

class PlaylistController {
    public function index() {}
    public function store() {}
    public function update() {}
    public function destroy() {}
}

and the routes are configured like this:

Route::resource('playlist', 'PlaylistController');

Running artisan apidoc:generate will fail:

In GenerateDocumentation.php line 223:

  Method create does not exist

In order to make it work, the route declaration must explicitly use only:

Route::resource('playlist', 'PlaylistController')->only(['index', 'store', 'update', 'destroy']);

This bug (?) can be fixed by checking the method existence before calling getMethod in GenerateDocumentation:223 e.g.

+       if (!$reflection->hasMethod($method)) return false;
        $comment = $reflection->getMethod($method)->getDocComment();

Happy to send a PR over if confirmed.

@shalvah
Copy link
Contributor

shalvah commented Dec 11, 2018

I don't have any Laravel API projects available at the moment, so I can't confirm. You're welcome to confirm on your machine and send in a PR (also add tests).

phanan added a commit to phanan-forks/laravel-apidoc-generator that referenced this issue Dec 11, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants