簡體   English   中英

Springfox Bean Validations @Size 注釋在 List 上無法正常工作

[英]Springfox Bean Validations @Size annotation does not work properly on List

我使用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上無法正常工作

這是springfox尚不支持的問題。 我修改了代碼,合並提交的代碼。 預計將在 3.0 版本中發布。 拉取請求鏈接

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM