-
-
Notifications
You must be signed in to change notification settings - Fork 312
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
xml-root-name not working #262
Comments
That's odd, because it works correctly for PHP annotations.
To test:
|
Actually I'm having exact same behavior with php annotations : <?php
namespace GMP\CommonAdminBundle\Entity;
use Gedmo\Mapping\Annotation as Gedmo;
use Doctrine\ORM\Mapping as ORM;
use Doctrine\Common\Collections\Collection;
use JMS\Serializer\Annotation as JMS;
/**
* Article
*
* @ORM\Table(name="articles")
* @ORM\Entity(repositoryClass="GMP\CommonAdminBundle\Entity\ArticleRepository")
* @Gedmo\SoftDeleteable(fieldName="deleted")
* @JMS\ExclusionPolicy("all")
* @JMS\XmlRoot("article")
*/
class Article
{
/**
* @var integer
*
* @ORM\Column(name="id", type="integer")
* @ORM\Id
* @ORM\GeneratedValue(strategy="AUTO")
* @JMS\Expose
* @JMS\SerializedName("id")
*/
private $id;
} which outputs as : <entry>
<id>1</id>
</entry> |
Same error here... |
@wjaspers what is you version of the bundle and the serializer? I have reproduced your exactly your User.php, and it is not working properly! |
when having a collection XmlRoot does not work. <?php
...
public function indexAction()
{
$entities = $this->getDoctrine()->getManager()->getRepository('BlahBlahBundle:Entity')->findAll();
$serializer = $this->get('serializer');
$out = $serializer->serialize($entities, 'xml');
var_dump($out);
die;
}
...
?> we have this output: <?xml version="1.0" encoding="UTF-8"?>
<result>
<entry id="11">
<origin_site><![CDATA[mainsite]]></origin_site>
<first_name><![CDATA[foo]]></first_name>
<last_name><![CDATA[bar]]></last_name>
<email><![CDATA[[email protected]]]></email>
</entry>
</result> and the Entity class is annotated in this way: <?php
.....
use JMS\Serializer\Annotation as Serializer;
/**
* Entity
*
* @Serializer\XmlRoot("entity_tag")
*/
class Entity {
.... |
+1 /**
* @Serializer\XmlRoot("name") get <entry>
<id>1</id>
</entry> |
This is also affecting me |
Same here, using yaml. |
I took a look at this bug. @schmittjoh : Any idea where I should look at to solve this ? Couldn't figure out what should init metadata in those classes. |
@XmlRootName only applies to the "root" node i.e. your object is directly passed to the If there is an issue with @XmlRootName not being used when your object is the root node, a first step would be to create a failing test case on the schmittjoh/serializer repository and request a pull. I'm closing this here as it also looks more like a misunderstanding of what @XmlRootName means. If you still think, it's an issue please create a new issue on schmittjoh/serializer containing:
|
this is still an issue in jms 1.1 |
For the people who are here, because they think it should set the name for their array/ArrayCollection children take a look at https://jmsyst.com/libs/serializer/master/reference/annotations#xmllist |
I have:
Result:
I forgot something?
The text was updated successfully, but these errors were encountered: