Skip to content

Commit

Permalink
fixed generate summary/description bug if route is a closure
Browse files Browse the repository at this point in the history
  • Loading branch information
mtrajano committed Aug 29, 2019
1 parent 1033109 commit a8fe6a6
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 3 deletions.
3 changes: 1 addition & 2 deletions src/Generator.php
Original file line number Diff line number Diff line change
Expand Up @@ -110,8 +110,7 @@ protected function getRouteUri(Route $route)

protected function generatePath()
{
$requestMethod = strtoupper($this->method);
$actionInstance = $this->action ? $this->getActionClassInstance($this->action) : null;
$actionInstance = is_string($this->action) ? $this->getActionClassInstance($this->action) : null;
$docBlock = $actionInstance ? ($actionInstance->getDocComment() ?: "") : "";

list($isDeprecated, $summary, $description) = $this->parseActionDocBlock($docBlock);
Expand Down
3 changes: 2 additions & 1 deletion tests/GeneratorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ public function testHasPaths($docs)
'/users',
'/users/{id}',
'/users/details',
'/users/ping',
'/api',
'/api/store',
], array_keys($docs['paths']));
Expand Down Expand Up @@ -206,7 +207,7 @@ public function testFiltersRoutes($routeFilter, $expectedRoutes)
public function filtersRoutesProvider()
{
return [
'No Filter' => [null, ['/users', '/users/{id}', '/users/details', '/api', '/api/store']],
'No Filter' => [null, ['/users', '/users/{id}', '/users/details', '/users/ping', '/api', '/api/store']],
'/api Filter' => ['/api', ['/api', '/api/store']],
'/=nonexistant Filter' => ['/nonexistant', []],
];
Expand Down
3 changes: 3 additions & 0 deletions tests/TestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ protected function getEnvironmentSetUp($app)
$app['router']->get('/users/{id}', 'Mtrajano\\LaravelSwagger\\Tests\\Stubs\\Controllers\\UserController@show');
$app['router']->post('/users', 'Mtrajano\\LaravelSwagger\\Tests\\Stubs\\Controllers\\UserController@store');
$app['router']->get('/users/details', 'Mtrajano\\LaravelSwagger\\Tests\\Stubs\\Controllers\\UserController@details');
$app['router']->get('/users/ping', function() {
return 'pong';
});
$app['router']->get('/api', 'Mtrajano\\LaravelSwagger\\Tests\\Stubs\\Controllers\\ApiController@index');
$app['router']->put('/api/store', 'Mtrajano\\LaravelSwagger\\Tests\\Stubs\\Controllers\\ApiController@store');
}
Expand Down

0 comments on commit a8fe6a6

Please sign in to comment.