【问题标题】:Springfox Bean Validations @Size annotation does not work properly on ListSpringfox Bean Validations @Size 注解在 List 上不能正常工作
【发布时间】:2020-02-18 14:46:59
【问题描述】:

我正在使用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】:

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-08-01
      • 1970-01-01
      • 1970-01-01
      • 2012-07-26
      • 1970-01-01
      相关资源
      最近更新 更多