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