首页 > 解决方案 > 有没有办法将 int 转换为 List在 Swagger 中为 @ApiModelProperty

问题描述

我想要隐蔽的 int 来列出 @ApiModelProperty

我使用 spring-fox swagger2 生成 API 规范,我们希望 ApiModel 中的属性日期支持 int 和 List。

@Data
@Immutable
@ApiModel(value = "Model", description = "Model")
public class CriteriaFields {
    @ApiModelProperty(required=false,value="date",example="XXX")
    private List<Integer> date;
}

现在只支持 List,如果我把 int 放在 swagger 页面中,它显示不能将 int 转换为 List。

Cannot deserialize instance of `java.util.ArrayList` out of VALUE_NUMBER_INT token; nested exception is com.fasterxml.jackson.databind.exc.MismatchedInputException: Cannot deserialize instance of `java.util.ArrayList` out of VALUE_NUMBER_INT token\n at [Source: (PushbackInputStream); line: 3, column: 15] (through reference chain:

标签: swagger-uispringfox

解决方案


推荐阅读