问题描述
我们有一个带有Springfox 2.9.2的Spring Boot 2应用程序来描述API,并且已用Swagger批注@ApiModelProperty标记了我们的API。我们的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)),...)
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
有人知道为什么Swagger2不能正常工作吗?
解决方法
尝试删除 dataType = "java.time.LocalDate"
。
它对我有用。
@ApiModelProperty(value = "mumbo-jumbo",example = "2018-03-20")
private String paymentAccountAge;