如何在swaggerui2中配置日期显示?

66bbxpm5  于 2021-07-16  发布在  Java
关注(0)|答案(0)|浏览(400)

我把招摇配置成这样:

  1. @EnableSwagger2
  2. public class SwaggerConfiguration {
  3. @Bean
  4. public Docket api() {
  5. return new Docket(DocumentationType.SWAGGER_2)
  6. .directModelSubstitute(ZonedDateTime.class, String.class)
  7. .directModelSubstitute(LocalDateTime.class, String.class)
  8. .apiInfo(apiInfo())
  9. .select()
  10. .apis(RequestHandlerSelectors.any())
  11. .paths(PathSelectors.any())
  12. .build();
  13. }
  14. }

在我的dto中,我有:

  1. @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd'T'HH:mm:ss.SSSSSSZ")
  2. private ZonedDateTime createdAt;

但愚蠢的 swagger 的用户界面显示错误的方式:

如何指示swaggerui将其显示为字符串值,并将日期接受为字符串?

暂无答案!

目前还没有任何答案,快来回答吧!

相关问题