Fix access to api->components in RouteMetadataDescriber (#1635)

* Fix access to api->components in RouteMetadataDescriber

* cs
This commit is contained in:
Guilhem Niot 2020-05-30 18:24:51 +02:00 committed by GitHub
parent 82d766bfe4
commit 4027fe8b6c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 28 additions and 1 deletions

View File

@ -73,7 +73,7 @@ final class RouteMetadataDescriber implements RouteDescriberInterface
private function getRefParams(OA\OpenApi $api, OA\Operation $operation): array
{
/** @var OA\Parameter[] $globalParams */
$globalParams = OA\UNDEFINED !== $api->components->parameters ? $api->components->parameters : [];
$globalParams = OA\UNDEFINED !== $api->components && OA\UNDEFINED !== $api->components->parameters ? $api->components->parameters : [];
$existingParams = [];
$operationParameters = OA\UNDEFINED !== $operation->parameters ? $operation->parameters : [];

View File

@ -0,0 +1,27 @@
<?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\RouteDescriber;
use Nelmio\ApiDocBundle\RouteDescriber\RouteMetadataDescriber;
use OpenApi\Annotations\OpenApi;
use PHPUnit\Framework\TestCase;
use Symfony\Component\Routing\Route;
class RouteMetadataDescriberTest extends TestCase
{
public function testUndefinedCheck()
{
$routeDescriber = new RouteMetadataDescriber();
$this->assertNull($routeDescriber->describe(new OpenApi([]), new Route('foo'), new \ReflectionMethod(__CLASS__, 'testUndefinedCheck')));
}
}