Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

JMS serializer yml datetime format

I have an Rest API built on Symfony 2.7 Framework with FOSRestBundle and JMSSerializerBundle. I have a look to yml reference and annotations.

I have choosen to define how each entity of my model is serialized with yml.

I have seen that we can serialize Datetime object on a specific format :

@JMS\Type("DateTime<'d-m-Y'>")

But I don't know the correct syntax used with yml definition, I have tried :

my_field:
  expose: true
  type: datetime
  format: 'd-m-Y'

And

my_field:
  expose: true
  type: datetime<'d-m-Y'>

I don't want to use Annotations because I have a lot of yaml files.

But the field is not serialized...

Anyone can help me ?

like image 325
Weenesta - Mathieu Dormeval Avatar asked Jan 10 '17 13:01

Weenesta - Mathieu Dormeval


1 Answers

I put it as an answer in case it helps more people:

my_field:
  expose: true
  type: DateTime<'d-m-Y'>
like image 123
Hokusai Avatar answered Oct 20 '22 21:10

Hokusai