mirror of
https://github.com/retailcrm/NelmioApiDocBundle.git
synced 2025-02-10 11:39:25 +03:00
add support for jms serializer inline property feature
This commit is contained in:
parent
be89b2be6c
commit
2fd95e2242
@ -93,8 +93,20 @@ class JMSModelDescriber implements ModelDescriberInterface, ModelRegistryAwareIn
|
|||||||
$reflection = new \ReflectionProperty($item->class, $item->name);
|
$reflection = new \ReflectionProperty($item->class, $item->name);
|
||||||
}
|
}
|
||||||
|
|
||||||
$property = $properties->get($annotationsReader->getPropertyName($reflection, $name));
|
|
||||||
$groups = $this->computeGroups($context, $item->type);
|
$groups = $this->computeGroups($context, $item->type);
|
||||||
|
|
||||||
|
if (true === $item->inline && isset($item->type['name'])) {
|
||||||
|
// currently array types can not be documented :-/
|
||||||
|
if (!in_array($item->type['name'], ['array', 'ArrayCollection'], true)) {
|
||||||
|
$inlineModel = new Model(new Type(Type::BUILTIN_TYPE_OBJECT, false, $item->type['name']), $groups);
|
||||||
|
$this->describe($inlineModel, $schema);
|
||||||
|
}
|
||||||
|
$context->popPropertyMetadata();
|
||||||
|
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
$property = $properties->get($annotationsReader->getPropertyName($reflection, $name));
|
||||||
$annotationsReader->updateProperty($reflection, $property, $groups);
|
$annotationsReader->updateProperty($reflection, $property, $groups);
|
||||||
} catch (\ReflectionException $e) {
|
} catch (\ReflectionException $e) {
|
||||||
$property = $properties->get($name);
|
$property = $properties->get($name);
|
||||||
|
34
Tests/Functional/Entity/JMSNote.php
Normal file
34
Tests/Functional/Entity/JMSNote.php
Normal file
@ -0,0 +1,34 @@
|
|||||||
|
<?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\Entity;
|
||||||
|
|
||||||
|
use JMS\Serializer\Annotation as Serializer;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* JMSNote.
|
||||||
|
*
|
||||||
|
* @Serializer\ExclusionPolicy("all")
|
||||||
|
*/
|
||||||
|
class JMSNote
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* @Serializer\Type("string")
|
||||||
|
* @Serializer\Expose
|
||||||
|
*/
|
||||||
|
private $long;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Serializer\Type("int")
|
||||||
|
* @Serializer\Expose
|
||||||
|
*/
|
||||||
|
private $short;
|
||||||
|
}
|
@ -180,6 +180,13 @@ class JMSUser
|
|||||||
*/
|
*/
|
||||||
private $deepFreeFormObjectCollection;
|
private $deepFreeFormObjectCollection;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Serializer\Type("Nelmio\ApiDocBundle\Tests\Functional\Entity\JMSNote")
|
||||||
|
* @Serializer\Inline()
|
||||||
|
* @Serializer\Expose
|
||||||
|
*/
|
||||||
|
private $notes;
|
||||||
|
|
||||||
public function setRoles($roles)
|
public function setRoles($roles)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
@ -192,6 +192,12 @@ class JMSFunctionalTest extends WebTestCase
|
|||||||
],
|
],
|
||||||
],
|
],
|
||||||
],
|
],
|
||||||
|
'long' => [
|
||||||
|
'type' => 'string',
|
||||||
|
],
|
||||||
|
'short' => [
|
||||||
|
'type' => 'integer',
|
||||||
|
],
|
||||||
],
|
],
|
||||||
], $this->getModel('JMSUser')->toArray());
|
], $this->getModel('JMSUser')->toArray());
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user