Skip to content
GitLab
Projects Groups Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
  • O openapi-generator
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 3,476
    • Issues 3,476
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 402
    • Merge requests 402
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Packages and registries
    • Packages and registries
    • Package Registry
    • Infrastructure Registry
  • Monitor
    • Monitor
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • OpenAPI Tools
  • openapi-generator
  • Issues
  • #9238
Closed
Open
Issue created Apr 12, 2021 by Administrator@rootContributor5 of 5 checklist items completed5/5 checklist items

[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
  1. Generate code from spec
  2. 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).

Assignee
Assign to
Time tracking