Hack date field versus date and time field

I use swagger to test my rest api, one of the properties of my entity class is a date field for which I need a date in the format yyyy-mm-dd, but the swagger model diagram shows this field as date- instead of a date field, so it gives a date with time and zone. How can I convert this date field to a date field?

I have a Java TimeEntry.java entity class, one of its properties is Date, it looks like this.

@ApiModelProperty(required = true)
@JsonFormat(pattern = DATE_FORMAT)
private Date date;

for this field, in the swagger user interface model diagram, the field date is displayed as "date": "2016-01-08T22: 34: 22.337Z", but I need it as "date": "2016-01-08".

I tried the following:

1.

@ApiModelProperty(required = true, dataType="date")  
@JsonFormat(pattern = DATE_FORMAT)   
private Date date;

2. ( OverrideConvertor), swagger-core 1.3 version mvn repo. 1.5 https://github.com/swagger-api/swagger-core/wiki/overriding-models

  1. -, 1.5 OverrideConvertor https://groups.google.com/forum/#!topic/swagger-swaggersocket/ChiknyHZiP4

, .

+4
2

( ) java.util.Date , -, . , @JsonFormat , - .

.

1) Joda LocalDate . private LocalDate date, .

2) java8 LocalDate, .

3). , , java.util.Date:

@ApiModelProperty(required = true, dataType = "org.joda.time.LocalDate")

, , swagger date.

+5

. springfox 2.3.0, springfox 2.2.2. swagger @ApiModelPreporty "", . 2.3.0 "" . , springfox 2.3.0, , , .

@ApiModelProperty(required = true,example = "2016-01-01")
@JsonFormat(pattern = DATE_FORMAT)
private LocalDate date; 

, :

https://github.com/springfox/springfox/issues/998

+2

Source: https://habr.com/ru/post/1623792/