Description
Right now the Kotlin client doesn't support binary responses, only JSON.
openapi-generator version
5.0.0-beta
OpenAPI declaration file content or url
It is impossible to consume this response with Kotlin right now:
responses:
'200':
description: The generated PDF
content:
application/pdf:
schema:
type: string
format: binary
Throws error responseBody currently only supports JSON body
Command line used for generation
Kotlin, gradle
Steps to reproduce
Make any request for a binary endpoint in Kotlin.
Related issues/PRs
Didn't see any.
Suggest a fix/enhancement
AbstractKotlinCodegen unfortunately maps the response type to java.io.File, which while convenient for sending a file request, is not well-suited to a response, because a File must refer to a file on disk.
It would be much preferable to change the type mapping to InputStream or something similar for the response only, but I couldn't figure out how to do this without breaking the request type mapping as well. Maybe there is some way to leverage the isResponseBinary property but it wasn't clear to me how to change this.
So I changed it to generate a tempfile in my PR. If we could make it be an InputStream that would be better, but it's not clear to me how.
Description
Right now the Kotlin client doesn't support binary responses, only JSON.
openapi-generator version
5.0.0-beta
OpenAPI declaration file content or url
It is impossible to consume this response with Kotlin right now:
Throws error
responseBody currently only supports JSON bodyCommand line used for generation
Kotlin, gradle
Steps to reproduce
Make any request for a binary endpoint in Kotlin.
Related issues/PRs
Didn't see any.
Suggest a fix/enhancement
AbstractKotlinCodegenunfortunately maps the response type tojava.io.File, which while convenient for sending a file request, is not well-suited to a response, because aFilemust refer to a file on disk.It would be much preferable to change the type mapping to
InputStreamor something similar for the response only, but I couldn't figure out how to do this without breaking the request type mapping as well. Maybe there is some way to leverage theisResponseBinaryproperty but it wasn't clear to me how to change this.So I changed it to generate a tempfile in my PR. If we could make it be an
InputStreamthat would be better, but it's not clear to me how.