以Springfox和Swagger-UI为例的当前日期

时间:2019-05-29 06:33:48

标签: java swagger swagger-ui springfox

使用SpringFox 2.9.2,如何将LocalDate字段的示例设置为当前日期?

我尝试过的一些例子:

1)LocalDate字段,无示例值

import io.swagger.annotations.ApiModelProperty;
import javax.validation.constraints.NotNull;
import java.time.LocalDate;

public class Request {
    @ApiModelProperty(notes = "Reservation date as YYYY-MM-DD", required = true)
    @NotNull
    public LocalDate date;
}

这显示了swagger-ui.html中的以下示例:

{
  "date": "string"
}

2)LocalDate字段,示例值

import io.swagger.annotations.ApiModelProperty;
import javax.validation.constraints.NotNull;
import java.time.LocalDate;

public class Request {
    @ApiModelProperty(example = "2019-05-29", notes = "Reservation date as YYYY-MM-DD", required = true)
    @NotNull
    public LocalDate date;
}

这显示了swagger-ui.html中的以下示例:

{
  "date": "2019-05-29"
}

按照格式设置,这正是我所要的,但明天仍将显示相同的值(而不是“ 2019-05-30”)。

3)LocalDateTime字段,无示例值

import io.swagger.annotations.ApiModelProperty;
import javax.validation.constraints.NotNull;
import java.time.LocalDateTime;

public class Request {
    @ApiModelProperty(notes = "Reservation date as YYYY-MM-DD", required = true)
    @NotNull
    public LocalDateTime date;
}

这显示了swagger-ui.html中的以下示例:

{
  "date": "2019-05-29T06:28:31.382Z"
}

否则,我还是按照我要找的东西,但是我不希望时间部分为T06:28:31.382Z

0 个答案:

没有答案