mirror of
https://github.com/retailcrm/NelmioApiDocBundle.git
synced 2025-02-09 02:59:27 +03:00
Fix nullable array properties (#1697)
* Fix nullable array properties * Fix tests & Remove weird leftover dump * Fix test Co-authored-by: Filip Benčo <filip.benco@websupport.sk>
This commit is contained in:
parent
34598be7ee
commit
9592c7ebfa
@ -19,6 +19,7 @@ use OpenApi\Annotations as OA;
|
||||
class ArrayPropertyDescriber implements PropertyDescriberInterface, ModelRegistryAwareInterface
|
||||
{
|
||||
use ModelRegistryAwareTrait;
|
||||
use NullablePropertyTrait;
|
||||
|
||||
/** @var PropertyDescriberInterface[] */
|
||||
private $propertyDescribers;
|
||||
@ -36,6 +37,7 @@ class ArrayPropertyDescriber implements PropertyDescriberInterface, ModelRegistr
|
||||
}
|
||||
|
||||
$property->type = 'array';
|
||||
$this->setNullableProperty($types[0], $property);
|
||||
$property = Util::getChild($property, OA\Items::class);
|
||||
|
||||
foreach ($this->propertyDescribers as $propertyDescriber) {
|
||||
|
@ -80,6 +80,11 @@ class User
|
||||
*/
|
||||
private $friend;
|
||||
|
||||
/**
|
||||
* @var User[]|null
|
||||
*/
|
||||
private $friends;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*
|
||||
@ -146,6 +151,10 @@ class User
|
||||
{
|
||||
}
|
||||
|
||||
public function setFriends(array $friends = [])
|
||||
{
|
||||
}
|
||||
|
||||
public function setDummy(Dummy $dummy)
|
||||
{
|
||||
}
|
||||
|
@ -195,6 +195,13 @@ class FunctionalTest extends WebTestCase
|
||||
['$ref' => '#/components/schemas/User'],
|
||||
],
|
||||
],
|
||||
'friends' => [
|
||||
'nullable' => true,
|
||||
'items' => [
|
||||
'$ref' => '#/components/schemas/User',
|
||||
],
|
||||
'type' => 'array',
|
||||
],
|
||||
'dummy' => [
|
||||
'$ref' => '#/components/schemas/Dummy2',
|
||||
],
|
||||
@ -460,7 +467,6 @@ class FunctionalTest extends WebTestCase
|
||||
public function testDefaultOperationId()
|
||||
{
|
||||
$operation = $this->getOperation('/api/article/{id}', 'get');
|
||||
var_dump($operation->operationId);
|
||||
$this->assertNull($operation->operationId);
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user