[BUG] Kotlin retrofit: binary response missing import
Created by: ghost
Bug Report Checklist
-
Have you provided a full/minimal spec to reproduce the issue? -
Have you validated the input using an OpenAPI validator (example)? -
Have you tested with the latest master to confirm the issue still exists? -
Have you searched for related issues/PRs? -
What's the actual output vs expected output?
Description
Having a binary response, leads to a missing import with jvm-retrofit2 library. The ResponseBody import is missing.
openapi-generator version
5.1.0
OpenAPI declaration file content or url
openapi: 3.0.3
info:
title: Test
version: 1.0.0
paths:
/image:
get:
responses:
'200':
description: Event image in JPEG format
content:
image/jpeg:
schema:
type: string
format: binary
Generation Details
openapi-generator generate -i spec.yaml -g kotlin --library jvm-retrofit2
Steps to reproduce
- Generate code from spec
- Check missing import in DefaultApi.kt:
package org.openapitools.client.apis
import org.openapitools.client.infrastructure.CollectionFormats.*
import retrofit2.http.*
import retrofit2.Call
import okhttp3.RequestBody
// MISSING: import okhttp3.ResponseBody
interface DefaultApi {
/**
*
*
* Responses:
* - 200: Event image in JPEG format
*
* @return [Call]<[ResponseBody]>
*/
@GET("image")
fun imageGet(): Call<ResponseBody>
}
Suggest a fix
Update the api.mustache: Add
{{#operation}}
{{#isResponseFile}}
import okhttp3.ResponseBody
{{/isResponseFile}}
{{/operation}}
at the bottom of the imports section (line 50).