mirror of
https://github.com/retailcrm/NelmioApiDocBundle.git
synced 2025-03-12 02:26:09 +03:00
add hateoas v3 compat
This commit is contained in:
parent
66bcf02903
commit
d15b4123c1
@ -13,6 +13,7 @@ namespace Nelmio\ApiDocBundle\ModelDescriber;
|
|||||||
|
|
||||||
use Doctrine\Common\Annotations\Reader;
|
use Doctrine\Common\Annotations\Reader;
|
||||||
use EXSyst\Component\Swagger\Schema;
|
use EXSyst\Component\Swagger\Schema;
|
||||||
|
use JMS\Serializer\Annotation\VirtualProperty;
|
||||||
use JMS\Serializer\Exclusion\GroupsExclusionStrategy;
|
use JMS\Serializer\Exclusion\GroupsExclusionStrategy;
|
||||||
use JMS\Serializer\Naming\PropertyNamingStrategyInterface;
|
use JMS\Serializer\Naming\PropertyNamingStrategyInterface;
|
||||||
use JMS\Serializer\SerializationContext;
|
use JMS\Serializer\SerializationContext;
|
||||||
@ -94,10 +95,18 @@ class JMSModelDescriber implements ModelDescriberInterface, ModelRegistryAwareIn
|
|||||||
|
|
||||||
$name = $this->namingStrategy ? $this->namingStrategy->translateName($item) : $item->serializedName;
|
$name = $this->namingStrategy ? $this->namingStrategy->translateName($item) : $item->serializedName;
|
||||||
// read property options from Swagger Property annotation if it exists
|
// read property options from Swagger Property annotation if it exists
|
||||||
if (null !== $item->reflection) {
|
try {
|
||||||
$property = $properties->get($annotationsReader->getPropertyName($item->reflection, $name));
|
if (property_exists($item, 'reflection') && null !== $item->reflection) {
|
||||||
$annotationsReader->updateProperty($item->reflection, $property, $groups);
|
$reflection = $item->reflection;
|
||||||
} else {
|
} elseif ($item instanceof VirtualProperty) {
|
||||||
|
$reflection = new \ReflectionProperty($item->class, $item->name);
|
||||||
|
} else {
|
||||||
|
$reflection = new \ReflectionProperty($item->class, $item->name);
|
||||||
|
}
|
||||||
|
|
||||||
|
$property = $properties->get($annotationsReader->getPropertyName($reflection, $name));
|
||||||
|
$annotationsReader->updateProperty($reflection, $property, $groups);
|
||||||
|
} catch (\ReflectionException $e) {
|
||||||
$property = $properties->get($name);
|
$property = $properties->get($name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -18,7 +18,7 @@ use Hateoas\Configuration\Annotation as Hateoas;
|
|||||||
*
|
*
|
||||||
* @Hateoas\Relation(name="example", attributes={"str_att":"bar", "float_att":5.6, "bool_att": false}, href="http://www.example.com")
|
* @Hateoas\Relation(name="example", attributes={"str_att":"bar", "float_att":5.6, "bool_att": false}, href="http://www.example.com")
|
||||||
* @Hateoas\Relation(name="route", href=@Hateoas\Route("foo"))
|
* @Hateoas\Relation(name="route", href=@Hateoas\Route("foo"))
|
||||||
* @Hateoas\Relation(name="route", attributes={"foo":"bar"}, embedded=@Hateoas\Embedded("expr(foo)"))
|
* @Hateoas\Relation(name="route", attributes={"foo":"bar"}, embedded=@Hateoas\Embedded("expr(service('xx'))"))
|
||||||
*/
|
*/
|
||||||
class BazingaUser
|
class BazingaUser
|
||||||
{
|
{
|
||||||
|
@ -43,7 +43,7 @@
|
|||||||
|
|
||||||
"api-platform/core": "^2.1.0",
|
"api-platform/core": "^2.1.0",
|
||||||
"friendsofsymfony/rest-bundle": "^2.0",
|
"friendsofsymfony/rest-bundle": "^2.0",
|
||||||
"willdurand/hateoas-bundle": "^1.0",
|
"willdurand/hateoas-bundle": "^1.0|^2.0",
|
||||||
"jms/serializer-bundle": "^2.0|^3.0"
|
"jms/serializer-bundle": "^2.0|^3.0"
|
||||||
},
|
},
|
||||||
"suggest": {
|
"suggest": {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user