mirror of
https://github.com/retailcrm/NelmioApiDocBundle.git
synced 2025-02-13 04:59:24 +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
|
class ArrayPropertyDescriber implements PropertyDescriberInterface, ModelRegistryAwareInterface
|
||||||
{
|
{
|
||||||
use ModelRegistryAwareTrait;
|
use ModelRegistryAwareTrait;
|
||||||
|
use NullablePropertyTrait;
|
||||||
|
|
||||||
/** @var PropertyDescriberInterface[] */
|
/** @var PropertyDescriberInterface[] */
|
||||||
private $propertyDescribers;
|
private $propertyDescribers;
|
||||||
@ -36,6 +37,7 @@ class ArrayPropertyDescriber implements PropertyDescriberInterface, ModelRegistr
|
|||||||
}
|
}
|
||||||
|
|
||||||
$property->type = 'array';
|
$property->type = 'array';
|
||||||
|
$this->setNullableProperty($types[0], $property);
|
||||||
$property = Util::getChild($property, OA\Items::class);
|
$property = Util::getChild($property, OA\Items::class);
|
||||||
|
|
||||||
foreach ($this->propertyDescribers as $propertyDescriber) {
|
foreach ($this->propertyDescribers as $propertyDescriber) {
|
||||||
|
@ -80,6 +80,11 @@ class User
|
|||||||
*/
|
*/
|
||||||
private $friend;
|
private $friend;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var User[]|null
|
||||||
|
*/
|
||||||
|
private $friends;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var string
|
* @var string
|
||||||
*
|
*
|
||||||
@ -146,6 +151,10 @@ class User
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function setFriends(array $friends = [])
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
public function setDummy(Dummy $dummy)
|
public function setDummy(Dummy $dummy)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
@ -195,6 +195,13 @@ class FunctionalTest extends WebTestCase
|
|||||||
['$ref' => '#/components/schemas/User'],
|
['$ref' => '#/components/schemas/User'],
|
||||||
],
|
],
|
||||||
],
|
],
|
||||||
|
'friends' => [
|
||||||
|
'nullable' => true,
|
||||||
|
'items' => [
|
||||||
|
'$ref' => '#/components/schemas/User',
|
||||||
|
],
|
||||||
|
'type' => 'array',
|
||||||
|
],
|
||||||
'dummy' => [
|
'dummy' => [
|
||||||
'$ref' => '#/components/schemas/Dummy2',
|
'$ref' => '#/components/schemas/Dummy2',
|
||||||
],
|
],
|
||||||
@ -460,7 +467,6 @@ class FunctionalTest extends WebTestCase
|
|||||||
public function testDefaultOperationId()
|
public function testDefaultOperationId()
|
||||||
{
|
{
|
||||||
$operation = $this->getOperation('/api/article/{id}', 'get');
|
$operation = $this->getOperation('/api/article/{id}', 'get');
|
||||||
var_dump($operation->operationId);
|
|
||||||
$this->assertNull($operation->operationId);
|
$this->assertNull($operation->operationId);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user