Forum Discussion

sairamkukadala's avatar
sairamkukadala
Frequent Visitor
6 years ago

Can we generate @JsonFormat on model variable using swagger-generater?

I have a variable in yml file

startDate:
 type:string
 format:date

I'm using swagger-generater to generate java code from yml.

It's generating a startDate variable as below

@JsonProperty("startDate")
private LocalDate startDate = null; 

But I need as below

@JsonProperty("startDate")
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd")
private LocalDate startDate = null; 

Can someone help me on this?

 

  • nmrao's avatar
    nmrao
    Champion Level 3
    Note that it will limit the end users to single date format than flexible.