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?
You can add x-field-extra-annotation to add anything annotation you need.
Document is here: https://openapi-generator.tech/docs/generators/java
startDate:
type:string
format:date
x-field-extra-annotation: '@com.fasterxml.jackson.annotation.JsonFormat(shape = com.fasterxml.jackson.annotation.JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd")'
Then generated model class will have annotation JsonFormat
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With