Hateoas
Hateoas copied to clipboard
Property group exclusion for embedded resource(s) is not working
Expected behaviour:
- Block is embedded within the Section,
- exclusion policy defined in Section should not allow Block's "title" property to render.
Actual:
- embedded Block still has its "title" present.
Code:
use Hateoas\Configuration\Annotation as Hateoas;
use JMS\Serializer\Annotation as Serializer;
/**
* @Serializer\ExclusionPolicy("all")
* @Hateoas\Relation("block",
* embedded = @Hateoas\Embedded(
* "expr(object.getBlock())",
* exclusion = @Hateoas\Exclusion(groups="extended" )
* )
* )
*/
class Section
{
public function getBlock(){...}
use Hateoas\Configuration\Annotation as Hateoas;
use JMS\Serializer\Annotation as Serializer;
/**
* @Serializer\ExclusionPolicy("all")
*/
class Block
{
/**
* @Serializer\Groups({"extended"})
* @Serializer\Expose
* @var string
*/
private $title;
...
}
Am I doing something wrong?
I noticed, that the JmsSerializer is not aware of any exclusion strategy for that property so it simply skips the rest of the checks.
refs #154 #141
@jkobus Did you find a solution to this?
No, not yet. Didn't have time to investigate further.
Okay i know that this issue is kinda old but...
I have very similar case, however for me annotations are working but yml mappings are not, to be more precise - exclude, expose, exclusion_policy provided by JMS are not being parsed, but (for example) virtual_properties are working fine.
If i'll use annotation like @jkobus mentioned, everything is working just fine, however i do use yml mapping mostly because of extending vendor models
I do use:
Package | version |
---|---|
willdurand/hateoas | 3.6.0 |
willdurand/hateoas-bundle | 2.1.0 |
jms/serializer | 3.9.0 |
jms/serializer-bundle | 3.7.0 |
symfony/* | 5.1.5 |