mirror of
https://github.com/retailcrm/NelmioApiDocBundle.git
synced 2025-03-12 10:36:09 +03:00
jms serializer group names are based on the internal property name, not on the serialized name (#1421)
This commit is contained in:
parent
7f78ef9ba6
commit
9bae1115d6
@ -74,14 +74,13 @@ class JMSModelDescriber implements ModelDescriberInterface, ModelRegistryAwareIn
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
$name = $this->namingStrategy->translateName($item);
|
|
||||||
$groups = $model->getGroups();
|
$groups = $model->getGroups();
|
||||||
|
|
||||||
$previousGroups = null;
|
$previousGroups = null;
|
||||||
if (isset($groups[$name]) && is_array($groups[$name])) {
|
if (isset($groups[$item->name]) && is_array($groups[$item->name])) {
|
||||||
$previousGroups = $groups;
|
$previousGroups = $groups;
|
||||||
$groups = $model->getGroups()[$name];
|
$groups = $groups[$item->name];
|
||||||
} elseif (!isset($groups[$name]) && !empty($this->previousGroups[$model->getHash()])) {
|
} elseif (!isset($groups[$item->name]) && !empty($this->previousGroups[$model->getHash()])) {
|
||||||
// $groups = $this->previousGroups[spl_object_hash($model)]; use this for jms/serializer 2.0
|
// $groups = $this->previousGroups[spl_object_hash($model)]; use this for jms/serializer 2.0
|
||||||
$groups = false === $this->propertyTypeUsesGroups($item->type) ? null : [GroupsExclusionStrategy::DEFAULT_GROUP];
|
$groups = false === $this->propertyTypeUsesGroups($item->type) ? null : [GroupsExclusionStrategy::DEFAULT_GROUP];
|
||||||
} elseif (is_array($groups)) {
|
} elseif (is_array($groups)) {
|
||||||
@ -92,6 +91,7 @@ class JMSModelDescriber implements ModelDescriberInterface, ModelRegistryAwareIn
|
|||||||
$groups = null;
|
$groups = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$name = $this->namingStrategy->translateName($item);
|
||||||
// read property options from Swagger Property annotation if it exists
|
// read property options from Swagger Property annotation if it exists
|
||||||
if (null !== $item->reflection) {
|
if (null !== $item->reflection) {
|
||||||
$property = $properties->get($annotationsReader->getPropertyName($item->reflection, $name));
|
$property = $properties->get($annotationsReader->getPropertyName($item->reflection, $name));
|
||||||
|
@ -57,7 +57,7 @@ class JMSController
|
|||||||
* @SWG\Response(
|
* @SWG\Response(
|
||||||
* response=200,
|
* response=200,
|
||||||
* description="Success",
|
* description="Success",
|
||||||
* @Model(type=JMSComplex::class, groups={"list", "details", "user" : {"list"}})
|
* @Model(type=JMSComplex::class, groups={"list", "details", "User" : {"list"}})
|
||||||
* )
|
* )
|
||||||
*/
|
*/
|
||||||
public function complexAction()
|
public function complexAction()
|
||||||
@ -69,7 +69,7 @@ class JMSController
|
|||||||
* @SWG\Response(
|
* @SWG\Response(
|
||||||
* response=200,
|
* response=200,
|
||||||
* description="Success",
|
* description="Success",
|
||||||
* @Model(type=JMSDualComplex::class, groups={"Default", "complex" : {"user" : {"details"}}})
|
* @Model(type=JMSDualComplex::class, groups={"Default", "complex" : {"User" : {"details"}}})
|
||||||
* )
|
* )
|
||||||
*/
|
*/
|
||||||
public function complexDualAction()
|
public function complexDualAction()
|
||||||
|
@ -35,8 +35,9 @@ class JMSComplex
|
|||||||
* @SWG\Property(ref=@Model(type=JMSUser::class))
|
* @SWG\Property(ref=@Model(type=JMSUser::class))
|
||||||
* @Serializer\Expose
|
* @Serializer\Expose
|
||||||
* @Serializer\Groups({"details"})
|
* @Serializer\Groups({"details"})
|
||||||
|
* @Serializer\SerializedName("user")
|
||||||
*/
|
*/
|
||||||
private $user;
|
private $User;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @Serializer\Type("string")
|
* @Serializer\Type("string")
|
||||||
|
Loading…
x
Reference in New Issue
Block a user