Feign client sending multipart/form-data request parameters as query params instead of request parts
Seregy opened this issue · 1 comments
Describe the bug
A dynamic Feign client generated from Spring MVC annotations sends @RequestParam
parameters as query params instead of request parts for multipart/form-data
requests.
As in Spring MVC @RequestParam
maps to both query parameters and parts in multipart requests, such definition may be ambiguous for the client. And although a Spring MVC server is capable of processing parameters passed as either query parameters or request parts, this may not be the case for other servers that will ignore query parameters for those requests.
Replacing @RequestParam
with @RequestPart
for such parameters resolves the issue.
Is this the expected behaviour and the main workaround should be the usage of @RequestPart
? Or is there another way to send such parameters as request parts for multipart/form-data requests?
Sample
Request definition for the client:
@RequestMapping(method = RequestMethod.POST,
value = "/server/resources",
produces = {"application/json"},
consumes = {"multipart/form-data"})
ResponseEntity<ApiResponse> createResource(@RequestPart(value = "file") MultipartFile file,
@RequestParam(value = "category", required = false) String category,
@RequestParam(value = "priority") int priority);
A more detailed example is available in the sample repository.
Additional context
Request interface gets generated from the external OpenAPI definition
Hello @Seregy, while with many scenarios, there's a feature parity between Spring MVC controller annotations and the ones used in SC OpenFeign, we do not strive for complete parity (which would also be impossible due to the intrinsic difference between client and server logic). We are not planning on supporting multipart/form-data
request parameters with @RequestParam
. Please use @RequestPart
.