mirror of
https://github.com/retailcrm/NelmioApiDocBundle.git
synced 2025-03-11 10:06:09 +03:00
Support using annotations only at the class level of controllers (#1668)
* Support using annotations only at the class level of controllers * Fix dependencies * Bump dependency
This commit is contained in:
parent
fe39acd6a8
commit
f420532121
@ -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;
|
||||
}
|
||||
|
||||
|
31
Tests/Functional/Controller/InvokableController.php
Normal file
31
Tests/Functional/Controller/InvokableController.php
Normal file
@ -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",
|
||||
|
Loading…
x
Reference in New Issue
Block a user