diff --git a/Describer/SwaggerPhpDescriber.php b/Describer/SwaggerPhpDescriber.php index a850273..f011e32 100644 --- a/Describer/SwaggerPhpDescriber.php +++ b/Describer/SwaggerPhpDescriber.php @@ -123,7 +123,7 @@ final class SwaggerPhpDescriber implements ModelRegistryAwareInterface return $v instanceof SWG\AbstractAnnotation; }); - if (0 === count($annotations)) { + if (0 === count($annotations) && 0 === count($classAnnotations[$declaringClass->getName()])) { continue; } diff --git a/Tests/Functional/Controller/InvokableController.php b/Tests/Functional/Controller/InvokableController.php new file mode 100644 index 0000000..5640aa6 --- /dev/null +++ b/Tests/Functional/Controller/InvokableController.php @@ -0,0 +1,31 @@ +assertFalse($modelProperties->has('bar')); $this->assertTrue($modelProperties->has('notwhatyouthink')); } + + public function testInvokableController() + { + $operation = $this->getOperation('/api/invoke', 'get'); + $this->assertSame('Invokable!', $operation->getResponses()->get(200)->getDescription()); + } } diff --git a/Tests/Functional/TestKernel.php b/Tests/Functional/TestKernel.php index d709ac5..32e9399 100644 --- a/Tests/Functional/TestKernel.php +++ b/Tests/Functional/TestKernel.php @@ -81,6 +81,7 @@ class TestKernel extends Kernel $routes->import(__DIR__.'/Controller/ApiController.php', '/', 'annotation'); $routes->import(__DIR__.'/Controller/ClassApiController.php', '/', 'annotation'); $routes->import(__DIR__.'/Controller/UndocumentedController.php', '/', 'annotation'); + $routes->import(__DIR__.'/Controller/InvokableController.php', '/', 'annotation'); $routes->import('', '/api', 'api_platform'); $routes->add('/docs/{area}', 'nelmio_api_doc.controller.swagger_ui')->setDefault('area', 'default'); $routes->add('/docs.json', 'nelmio_api_doc.controller.swagger'); diff --git a/composer.json b/composer.json index 393d2cd..3a77a8c 100644 --- a/composer.json +++ b/composer.json @@ -37,7 +37,7 @@ "symfony/cache": "^3.4|^4.0|^5.0", "symfony/phpunit-bridge": "^3.4.24|^4.0|^5.0", "symfony/stopwatch": "^3.4|^4.0|^5.0", - "symfony/routing": "^3.4|^4.0|^5.0", + "symfony/routing": "^3.4.42|^4.0|^5.0", "sensio/framework-extra-bundle": "^3.0.13|^4.0|^5.0", "doctrine/annotations": "^1.2", "doctrine/common": "^2.4",