swagger-ui中测试接口(enum传值) 报400错误
swagger-ui中测试接口(enum传值) 报400错误
PriceRuleController:
@PostMapping("/update")
@ApiOperation(value = "更新阶梯价")
public ResBody updatePriceRule(@ModelAttribute PriceRuleBo priceRuleBo) {
...
@InitBinder
protected void initBinder(WebDataBinder binder) {
binder.registerCustomEditor(String.class, new StringTrimmerEditor(true));
binder.registerCustomEditor(Date.class, new DateEditor(true));
}
public class PriceRuleBo implements Serializable {
private String skuId;
private String priceRule;
private PriceRuleType priceRuleType;
//set get ...
@JsonFormat(shape = JsonFormat.Shape.OBJECT)
public enum PriceRuleType implements PairsEnum<PriceRuleType> {
LADDER_PRICE(1, "阶梯价"), FULL_REDUCTION(2, "满减");
private int value;
private String key;
PriceRuleType(int value, String key) {
this.value = value;
this.key = key;
}
public int getValue() {
return value;
}
public String getKey() {
return key;
}
传值:
priceRuleType=1
测试后发现swagger-ui 中报错,但是RESTClient中测试OK,