OpenAPITools / OpenAPITools/openapi-generator

[BUG] Java client (OkHttp) uses java.io.File for file parameters, instead of an InputStream

Open
#7,941 2 comments 2 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Issue: Bug
Dominant language
Java
Stars
26.8k
Forks
7.7k
PR merge metrics
PR metrics pending

Description

Bug Report Checklist

There is a serious design flaw in the Java client generated by default. Open to workarounds, have not been able to find one so far.

Description

Currently, if you have a binary string input parameter, the generated client takes a parameter of java.io.File. This is wrong because it means that you can only pass in a "local file" as a parameter. You cannot pass in a memory stream, which would be the more common case.

There does not seem to be an option to configure this, thus rendering the generated client completely useless for APIs that take in binary string / file parameter types. This is a huge issue. Would love to know if there is a workaround.

openapi-generator version

openapi-generator-cli-5.0.0-beta2.jar

OpenAPI declaration file content or url

https://api.cloudmersive.com/swagger/api/convert

Generation Details

See above

Steps to reproduce

See above

Related issues/PRs

N/A

Suggest a fix

Offer an option to use InputStream

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 by generating the Java client from the linked Cloudmersive Swagger declaration with openapi-generator-cli-5.0.0-beta2.jar and inspect how binary string or file parameters are represented. Trace the generated client and generator configuration for a way to use InputStream, then verify that generated APIs accept in-memory streams rather than only java.io.File.

Written by the indexing model from the issue text.

Assessment

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.