I don't understand why the annotation do nothing on my GET REST API. I have the JMS Serializer in vendor with all the class.. but when i call my webservice, there are all my properties which appears.. Whereas i did an @ExlusionPolicy("all") and just @Expose on the ID property..
This is my Entity Product :
<?php
namespace GroupeGC\Bundle\ProductBundle\Entity;
use Doctrine\ORM\Mapping as ORM;
use Jms\Serializer\Annotation as JMS;
/**
* Product
*
* @ORM\Table(name="gc_product")
* @ORM\Entity
* @JMS\ExclusionPolicy("all")
*
*/
class Product
{
/**
* @var integer
*
* @ORM\Column(name="id", type="integer")
* @ORM\Id
* @ORM\GeneratedValue(strategy="IDENTITY")
* @JMS\Type("integer")
* @JMS\Expose
*/
private $id;
/**
* @var string
*
* @ORM\Column(name="code", type="string", length=255, nullable=false)
*/
private $code;
/**
* @var string
*
* @ORM\Column(name="label", type="string", length=255, nullable=true)
*
*/
private $label;
/**
* @var float
* @ORM\Column(name="volume", type="float")
*
*/
private $volume;
/**
* @var float
* @ORM\Column(name="weight", type="float")
*/
private $weight;
/**
* Get id
*
* @return integer
*/
public function getId()
{
return $this->id;
}
/**
* Set code
*
* @param string $code
* @return Product
*/
public function setCode($code)
{
$this->code = $code;
return $this;
}
/**
* Get code
*
* @return string
*/
public function getCode()
{
return $this->code;
}
/**
* Set label
*
* @param string $label
* @return Product
*/
public function setLabel($label)
{
$this->label = $label;
return $this;
}
/**
* Get label
*
* @return string
*/
public function getLabel()
{
return $this->label;
}
public function getVolume() {
return $this->volume;
}
public function setVolume($volume) {
$this->volume = $volume;
return $this;
}
public function getWeight() {
return $this->weight;
}
public function setWeight($weight) {
$this->weight = $weight;
return $this;
}
But we can see that , normaly, i just should have the id propertie which should appear in my JSON , whereas i have all propertie.. and i don't understand.
EDIT 1 : This is the fos_rest config in app/config :
fos_rest:
view:
failed_validation: HTTP_BAD_REQUEST
default_engine: php
formats:
json: true
xml: true
format_listener:
prefer_extension: true
body_listener:
decoders:
json: fos_rest.decoder.json
xml: fos_rest.decoder.xml
routing_loader:
default_format: json
fos_js_routing:
routes_to_expose: [oro_*]
i don't think there are a problem here ..