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,


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM