Support using annotations only at the class level of controllers ()

* Support using annotations only at the class level of controllers

* Fix dependencies

* Bump dependency
This commit is contained in:
Guilhem Niot 2020-07-11 17:53:09 +02:00 committed by GitHub
parent fe39acd6a8
commit f420532121
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 40 additions and 2 deletions

@ -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;
}

@ -0,0 +1,31 @@
<?php
/*
* This file is part of the NelmioApiDocBundle package.
*
* (c) Nelmio
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Nelmio\ApiDocBundle\Tests\Functional\Controller;
use Swagger\Annotations as SWG;
use Symfony\Component\Routing\Annotation\Route;
/**
* Prevents a regression (see https://github.com/nelmio/NelmioApiDocBundle/issues/1559).
*
* @Route("/api/invoke", host="api.example.com", name="invokable", methods={"GET"})
* @SWG\Response(
* response=200,
* description="Invokable!"
* )
*/
class InvokableController
{
public function __invoke()
{
}
}

@ -423,4 +423,10 @@ class FunctionalTest extends WebTestCase
$this->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());
}
}

@ -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');

@ -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",