huangminsi opened a new issue, #3696: URL: https://github.com/apache/servicecomb-java-chassis/issues/3696
用户提交的请求参数中Enum值不在swagger的yaml约束的范围内,例如swagger的yaml约束operation为“1”或“2”,输入“operation”:“”或“operation”:“3”,EnumDeserializerl类中使用Jackson解析均会均会抛出JsonMappingException异常,但是RestCodec的restToArgs方法未捕获JsonMappingException,只是使用了Exception来捕获异常但并未获取异常的字段,导致使用spi 机制实现ProduceJsonProcessor时,无法获取框架解析异常的字段,我们需要在RestCodec中捕获json异常,以便于使用ProduceJsonProcessor接收并处理,并向用户展示请求参数中导致异常的字段;建议RestCodec.restToArgs()中使用JsonMappingException.getPath().get(i).getFieldName()接收多个path,并使用throw new InvocationException(Status.BAD_REQUEST, ErrorCode.PARAM_INVALID, stb.toString());把异常抛给ProduceJsonProcessor处理 (或使用InvalidFormatException,但是由于主要是枚举类解� ��会出现异常,所以也可使用JsonMappingException处理) -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
