英文:
@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;
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论