@ApiModelProperty中的dataType java.time.LocalDate无法解析

huangapple go评论83阅读模式
英文:

@ApiModelProperty with dataType java.time.LocalDate not resolvable

问题

我们有一个使用Spring Boot 2的应用程序,其中集成了Springfox 2.9.2来描述API,我们在API中使用Swagger注解@ApiModelProperty进行标注。我们的API中有类似这样的内容:

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

我们通过以下方式配置了Springfox来使用Swagger2:

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

然而,Swagger文档页面出现了错误:

    错误
    隐藏
    在 paths./startAuth.post.parameters.1.schema.properties.accountInfo.properties.paymentAccountAge.$ref 处的解析器错误
    由于无法解析指针,因此无法解析引用: /definitions/LocalDate在文档中不存在

有任何关于Swagger2没有正常工作的想法吗?

英文:

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. We have something like this in our API:

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

We have configured Swagger2 via Springfox as follows:

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

However the Swagger Documentation Page is producing errors:

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?

答案1

得分: 1

尝试删除 dataType = "java.time.LocalDate"
对我来说有效。

@ApiModelProperty(value = "胡言乱语", example = "2018-03-20")
private String paymentAccountAge;
英文:

Try to remove dataType = "java.time.LocalDate".
It works for me.

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

huangapple
  • 本文由 发表于 2020年8月24日 22:48:35
  • 转载请务必保留本文链接:https://go.coder-hub.com/63563367.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定