Springfox Bean验证@Size注释在列表上无法正常工作

问题描述 投票:1回答:1

我正在使用springfox bean验证程序将字段限制信息提取到生成的swagger json文件中,这是我使用的方式:

    @ApiModelProperty("str1")
    @Size(min = 1, max = 200, message = "length 1-200")
    private String str1;

    @ApiModelProperty("list1")
    @Size(min = 1, max = 100, message = "size 1-100")
    private List<String> list1;

在生成的json文件中:

str1:- {
  type: "string",
  description: "str1",
  allowEmptyValue: false,
  minLength: 1,
  maxLength: 200
},
list1:- {
  type: "array",
  description: "list1",
  allowEmptyValue: false,
  items:- {
    type: "string"
  }
}

[@Size批注在List上无法正常使用

java spring-boot swagger bean-validation springfox
1个回答
0
投票

这是springfox尚不支持的问题。我已经修改了代码,提交的代码已合并。预计将在3.0版中发布。pull request link

© www.soinside.com 2019 - 2024. All rights reserved.