swagger-api / swagger-api/swagger-codegen

[Java] Support for multipart upload other than java.io.File in Feign client

Open
#7,923 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Mustache
Stars
17.8k
Forks
6k
PR merge metrics
No merged PRs in 30d

Description

Description

Java Feign client generates endpoints with "multipart/form-data" payload in the following way (example from petstore sample):

ModelApiResponse uploadFile(@Param("petId") Long petId, @Param("additionalMetadata") String additionalMetadata, @Param("file") File file);

Notice the file parameter of type java.io.File in the api signature.

This seems counter-intuitive to me, as you may want to not only upload files stored on disk, but data that's just held in-memory.
Currently one may be forced to write the data to a file in order to call the generated method.

I'd suggest to declare byte[] instead, or at least provide an option for that in the config options.

Swagger-codegen version

2.3.1

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the generated PetApi.java example linked in the issue and inspect how Java Feign multipart/form-data parameters are represented. Determine how an in-memory upload type or configuration option should be exposed, then verify that generated client signatures support uploads without requiring java.io.File.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
api
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.