Skip to content

Commit

Permalink
Ignore Type::$nullable (#1391)
Browse files Browse the repository at this point in the history
  • Loading branch information
GuilhemN authored Aug 29, 2018
1 parent 0e72b64 commit 9983318
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 0 deletions.
2 changes: 2 additions & 0 deletions ModelDescriber/ObjectModelDescriber.php
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,8 @@ public function describe(Model $model, Schema $schema)
$property->setType('string');
$property->setFormat('date-time');
} else {
$type = new Type($type->getBuiltinType(), false, $type->getClassName(), $type->isCollection(), $type->getCollectionKeyType(), $type->getCollectionValueType()); // ignore nullable field

$property->setRef(
$this->modelRegistry->register(new Model($type, $model->getGroups()))
);
Expand Down
9 changes: 9 additions & 0 deletions Tests/Functional/Entity/User.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,11 @@ class User
*/
private $users;

/**
* @var User|null
*/
private $friend;

/**
* @var string
*
Expand Down Expand Up @@ -118,6 +123,10 @@ public function setUsers(array $users)
{
}

public function setFriend(self $friend = null)
{
}

public function setDummy(Dummy $dummy)
{
}
Expand Down
5 changes: 5 additions & 0 deletions Tests/Functional/FunctionalTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ public function testFetchArticleAction()
$modelProperties = $this->getModel('Article')->getProperties();
$this->assertCount(1, $modelProperties);
$this->assertTrue($modelProperties->has('author'));
$this->assertSame('#/definitions/User2', $modelProperties->get('author')->getRef());

$this->assertFalse($modelProperties->has('content'));
}

Expand Down Expand Up @@ -209,6 +211,9 @@ public function testUserModel()
],
'type' => 'array',
],
'friend' => [
'$ref' => '#/definitions/User',
],
'dummy' => [
'$ref' => '#/definitions/Dummy2',
],
Expand Down

0 comments on commit 9983318

Please sign in to comment.