-
-
Notifications
You must be signed in to change notification settings - Fork 846
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[ Bug ] NelmioApiDoc: Serialization groups are ignored for collectionOperations #728
Comments
|
Indeed, my bad. They show up as they should in the |
No it doesn't, but I think I realized the nature of its behavior. |
@karser The normalization/denorrmalization context specified for a specific operation should be the only one in use, with fallback to the one declared at resource level. If you see a different behaviour, it's a bug. Your assumption in the first comment is correct. |
Referring to your example, when you do
and the returned fields are:
|
I was looking into this, @teohhanhui it does work properly when posting a ressource, correct me if i'm wrong but : When using something dummy but similar <?php
namespace AppBundle\Entity;
use Doctrine\ORM\Mapping as ORM;
use ApiPlatform\Core\Annotation\ApiResource;
use Symfony\Component\Serializer\Annotation\Groups;
/**
* Dummy
* @ApiResource(attributes={
* "normalization_context"={"groups"={"dummy_out"}},
* "denormalization_context"={"groups"={"dummy_in"}}
* },
* collectionOperations={
* "get"={"method"="GET"},
* "post"={"method"="POST"},
* "customDummy"={
* "path"="/custom/dummy",
* "method"="POST",
* "normalization_context"={"groups"={"dummy_out"}},
* "denormalization_context"={"groups"={"custom_dummy"}}
* }
* }
* )
* @ORM\Table(name="dummy")
* @ORM\Entity(repositoryClass="AppBundle\Repository\DummyRepository")
*/
class Dummy
{
/**
* @var int
*
* @ORM\Column(name="id", type="integer")
* @ORM\Id
* @ORM\GeneratedValue(strategy="AUTO")
* @Groups({"dummy_out"})
*/
private $id;
/**
* @var string
*
* @ORM\Column(name="string", type="string", length=255)
* @Groups({"dummy_out", "custom_dummy"})
*/
private $string;
/**
* @var int
*
* @ORM\Column(name="gerard", type="integer")
* @Groups({"custom_dummy"})
*/
private $gerard;
/**
* @var int
*
* @ORM\Column(name="test", type="integer", nullable=true)
* @Groups({"dummy_in"})
*/
private $test;
/**
* @return int
*/
public function getTest()
{
return $this->test;
}
/**
* @param int $test
*/
public function setTest($test)
{
$this->test = $test;
}
/**
* Get id
*
* @return int
*/
public function getId()
{
return $this->id;
}
/**
* Set string
*
* @param string $string
*
* @return Dummy
*/
public function setString($string)
{
$this->string = $string;
return $this;
}
/**
* Get string
*
* @return string
*/
public function getString()
{
return $this->string;
}
/**
* Set gerard
*
* @param integer $gerard
*
* @return Dummy
*/
public function setGerard($gerard)
{
$this->gerard = $gerard;
return $this;
}
/**
* Get gerard
*
* @return int
*/
public function getGerard()
{
return $this->gerard;
}
} @karser correct me if i'm wrong but we are talking about the parameter return by NelmioApiDoc / Swagger Doc ? |
@Simperfit right, this issue is related to docs parameters only. |
@Simperfit is this fixed? |
@soyuka I don't think this is totally fixed. Because of nelmio I don't think we can go further than what i've done. |
I don't think we can do further with this |
Probably there is related closed issue but I can reproduce this using v2.0.0-beta.3 as well as master.
There is a bug somewhere in ApiPlatformParser that provides parsed attributes for NelmioApiDoc.
It should provide denormalization_context from collectionOperations (e.g "registration"), in fact, it returns global (e.g "write")
The text was updated successfully, but these errors were encountered: