zoukankan      html  css  js  c++  java
  • 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,

  • 相关阅读:
    A. Generous Kefa
    1031 骨牌覆盖
    1074 约瑟夫环 V2
    1073 约瑟夫环
    1562 玻璃切割
    Ants
    1024 矩阵中不重复的元素
    1014 X^2 Mod P
    1135 原根
    1010 只包含因子2 3 5的数
  • 原文地址:https://www.cnblogs.com/lanqie/p/9804016.html
Copyright © 2011-2022 走看看