Skip to content

Commit a8fe6a6

Browse files
committed
fixed generate summary/description bug if route is a closure
1 parent 1033109 commit a8fe6a6

File tree

3 files changed

+6
-3
lines changed

3 files changed

+6
-3
lines changed

src/Generator.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -110,8 +110,7 @@ protected function getRouteUri(Route $route)
110110

111111
protected function generatePath()
112112
{
113-
$requestMethod = strtoupper($this->method);
114-
$actionInstance = $this->action ? $this->getActionClassInstance($this->action) : null;
113+
$actionInstance = is_string($this->action) ? $this->getActionClassInstance($this->action) : null;
115114
$docBlock = $actionInstance ? ($actionInstance->getDocComment() ?: "") : "";
116115

117116
list($isDeprecated, $summary, $description) = $this->parseActionDocBlock($docBlock);

tests/GeneratorTest.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ public function testHasPaths($docs)
7676
'/users',
7777
'/users/{id}',
7878
'/users/details',
79+
'/users/ping',
7980
'/api',
8081
'/api/store',
8182
], array_keys($docs['paths']));
@@ -206,7 +207,7 @@ public function testFiltersRoutes($routeFilter, $expectedRoutes)
206207
public function filtersRoutesProvider()
207208
{
208209
return [
209-
'No Filter' => [null, ['/users', '/users/{id}', '/users/details', '/api', '/api/store']],
210+
'No Filter' => [null, ['/users', '/users/{id}', '/users/details', '/users/ping', '/api', '/api/store']],
210211
'/api Filter' => ['/api', ['/api', '/api/store']],
211212
'/=nonexistant Filter' => ['/nonexistant', []],
212213
];

tests/TestCase.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@ protected function getEnvironmentSetUp($app)
1717
$app['router']->get('/users/{id}', 'Mtrajano\\LaravelSwagger\\Tests\\Stubs\\Controllers\\UserController@show');
1818
$app['router']->post('/users', 'Mtrajano\\LaravelSwagger\\Tests\\Stubs\\Controllers\\UserController@store');
1919
$app['router']->get('/users/details', 'Mtrajano\\LaravelSwagger\\Tests\\Stubs\\Controllers\\UserController@details');
20+
$app['router']->get('/users/ping', function() {
21+
return 'pong';
22+
});
2023
$app['router']->get('/api', 'Mtrajano\\LaravelSwagger\\Tests\\Stubs\\Controllers\\ApiController@index');
2124
$app['router']->put('/api/store', 'Mtrajano\\LaravelSwagger\\Tests\\Stubs\\Controllers\\ApiController@store');
2225
}

0 commit comments

Comments
 (0)