JMSSerializerBundle icon indicating copy to clipboard operation
JMSSerializerBundle copied to clipboard

Expose `field_name` with discriminator map

Open Sydney-o9 opened this issue 11 years ago • 1 comments

Is there a way to expose the field name when using a discriminator map?

Acme\UserBundle\Entity\User:
  exclusion_policy: ALL
  discriminator:
        field_name: type
        map:
            userType1: Acme\UserBundle\Entity\userType1
            userType2: Acme\UserBundle\Entity\userType2

I tried:

//...
  properties:
    type:
      expose: true

But this doesn't work... any idea if this is possible?

Sydney-o9 avatar Oct 18 '13 04:10 Sydney-o9

The discriminator field_name is an actual field in the serialized data. So, your data should look something like:

{
    "type": "userType1"
}

josephdpurcell avatar Oct 09 '14 01:10 josephdpurcell