Ask a Question

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

sairamkukadala
Frequent Visitor

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?

 

1 REPLY 1
nmrao
Community Hero

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

Note that it will limit the end users to single date format than flexible.


Regards,
Rao.
cancel
Showing results for 
Search instead for 
Did you mean: