You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
[Optional] Sponsorship to speed up the bug fix or feature request (example)
Description
I have a project using the Kotlin generator and jvm-retrofit2 as the library. For file uploads, my OpenAPI schema has the following request body definition:
The resulting interface uses java.io.File as the body for the Retrofit interface. However, Retrofit doesn't support File for file uploads out of the box, resulting in an exception at runtime.
Adding an instance of this FileConverterFactory to the list of converter factories when creating the API client makes Retrofit perfectly happy to send File objects in its requests.
The text was updated successfully, but these errors were encountered:
Bug Report Checklist
Description
I have a project using the Kotlin generator and
jvm-retrofit2
as the library. For file uploads, my OpenAPI schema has the following request body definition:The resulting interface uses
java.io.File
as the body for the Retrofit interface. However, Retrofit doesn't supportFile
for file uploads out of the box, resulting in an exception at runtime.openapi-generator version
7.8.0
OpenAPI declaration file content or url
https://github.com/fyreplace/fyreplace-android/blob/develop/app/src/main/assets/openapi.yaml
Generation Details
The code is generated using the official Gradle plugin.
Steps to reproduce
./gradlew openapiGenerate
inside the repositoryapp/build/openapi/src/main/kotlin/app/fyreplace/api/UsersEndpointApi.kt
, and look forsetCurrentUserAvatar()
Related issues/PRs
Suggest a fix
A custom Converter for files can be created to handle files in request bodies. I have managed to make my uploads work with the following code:
The equivalent Java implementation would look something like this:
Adding an instance of this
FileConverterFactory
to the list of converter factories when creating the API client makes Retrofit perfectly happy to sendFile
objects in its requests.The text was updated successfully, but these errors were encountered: