swagger-api / swagger-api/swagger-codegen-generators
[java] resttemplate library doesn't support API with response type:string and format:binary
Nobody has claimed this yet.
- Dominant language
- Mustache
- Stars
- 299
- Forks
- 439
- PR merge metrics
- No merged PRs in 30d
Description
- Use a openapi json that describes an API with the following configuration
responses:
"200":
description: Your request was successful
content:
application/json;charset=UTF-8:
schema:
type: string
format: binary
- Use generator java with the following options
{
"dateLibrary":"legacy",
"library":"resttemplate"
}
- The client is not correctly generated to support the file download using Spring Rest Template framework.
ResponseEntity<T> responseEntity = restTemplate.exchange(requestEntity, returnType);
Where T is File and returnType is ParameterizedTypeReference<File>(). In this way File is treated as a json object to be mapped to the response.
An alternative piece of code must be generated to support the download of a generic binary stream to a tmp directory (like for example with the jersey2 library) and the use of class File as returned object to read that
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the generated RestTemplate client and the ResponseEntity exchange call shown in the report, then compare its binary download handling with the jersey2 library. Done means a response declared as string with format binary is downloaded to a temporary location and returned through File rather than JSON mapping.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java, spring
- Domain
- api, tooling
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100