OpenFeign / feign-form

Open Feign form encoder
Apache License 2.0
291 stars 81 forks source link

FormEncoder bug #109

Open redjiang opened 2 years ago

redjiang commented 2 years ago

https://github.com/OpenFeign/feign-form/blob/98e51d187f1b7acba3b39d1131371b761d87259b/feign-form/src/main/java/feign/form/FormEncoder.java#L95

if bodyType‘s typeName is "java.util.map<java.lang.String, java.lang.Object>" cannot correct match

eg: @RequestLine("POST /user") @Headers("Content-Type: application/x-www-form-urlencoded") void addUser (Map<String,Object> stringObjectMap);

molsza commented 2 years ago

It also cannot recognize the org.springframework.util.MultiValueMap.

So for example this method will never send a body:

  @PostMapping(consumes = MediaType.APPLICATION_FORM_URLENCODED)
  ResponseEntity<ObjectNode> requestForSomething(@RequestBody MultiValueMap<String, String> params);

The workaround for this is

  @PostMapping(consumes = MediaType.APPLICATION_FORM_URLENCODED)
  ResponseEntity<ObjectNode> requestForSomething(@RequestBody Map<String, ? extends Object> params);