The problem (one of the problems actually) with java.util.Date
is that it's really a date-time, and swagger correctly detects it as such. I do understand that the @JsonFormat
is a workaround for this as well--swagger does not support that annotation during it's type detection.
You have three options to properly handle date types.
1) Use Joda's LocalDate
as the datatype. If you declared private LocalDate date
, it would appear correctly.
2) Use java8's LocalDate
, same as above.
3) Tell swagger to use either of the above when detecting the type in the annotation, but keep the property as type java.util.Date
:
@ApiModelProperty(required = true, dataType = "org.joda.time.LocalDate")
Then, when scanning, swagger will detect this as a date
formatted string.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…