简体   繁体   English

数据类型为 java.time.LocalDate 的 @ApiModelProperty 无法解析

[英]@ApiModelProperty with dataType java.time.LocalDate not resolvable

We have a Spring Boot 2 application with Springfox 2.9.2 to describe the API and we have marked our API with Swagger annotations @ApiModelProperty.我们有一个带有 Springfox 2.9.2 的 Spring Boot 2 应用程序来描述 API,我们已经用 Swagger 注释 @ApiModelProperty 标记了我们的 API。 We have something like this in our API:我们的 API 中有这样的东西:

@ApiModelProperty(value = "mumbo-jumbo", dataType = "java.time.LocalDate", example = "2018-03-20")
private String paymentAccountAge;

We have configured Swagger2 via Springfox as follows:我们通过 Springfox 配置 Swagger2 如下:

return new Docket(DocumentationType.SWAGGER_2)
    ...
    .alternateTypeRules(
       ...
       newRule(typeResolver.resolve(LocalDate.class), typeResolver.resolve(String.class)),
       ...)

However the Swagger Documentation Page is producing errors:然而,Swagger 文档页面产生了错误:

Errors
Hide
Resolver error at paths./startAuth.post.parameters.1.schema.properties.accountInfo.properties.paymentAccountAge.$ref
Could not resolve reference because of: Could not resolve pointer: /definitions/LocalDate does not exist in document

Any idea why Swagger2 ist not working properly?知道为什么 Swagger2 不能正常工作吗?

Try to remove dataType = "java.time.LocalDate" .尝试删除dataType = "java.time.LocalDate" It works for me.这个对我有用。

@ApiModelProperty(value = "mumbo-jumbo", example = "2018-03-20")
private String paymentAccountAge;

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM