Nik*_*ita 3 java documentation swagger microservices swagger-2.0
我有一个包含 Java 8 LocalDate 类型字段的 DTO。使用 Jackson 注释可以将格式设置为ISO.DATE并且一切正常。但是 Swagger(我有版本 2.+)看到LocalDate.classas 对象
LocalDate {
month (integer, optional),
year (integer, optional)
}
Run Code Online (Sandbox Code Playgroud)
(这是真的,但是...)我想将其表示为带有格式的字符串,因为它适用于util.Date. 我该如何解决?
我遇到了同样的问题,所以我添加了
@Bean
public Docket docket() {
return new Docket(DocumentationType.SWAGGER_2)
.groupName("name")
.directModelSubstitute(LocalDateTime.class, String.class)
.directModelSubstitute(LocalDate.class, String.class)
.directModelSubstitute(LocalTime.class, String.class)
.directModelSubstitute(ZonedDateTime.class, String.class)
.apiInfo(apiInfo())
.select()
.paths(paths())
.build();
}
Run Code Online (Sandbox Code Playgroud)
在案卷配置中。
directModelSubstitute让招摇治疗LocalDate的String类
| 归档时间: |
|
| 查看次数: |
9183 次 |
| 最近记录: |