OpenAPITools / OpenAPITools/openapi-generator

[REQ] [Kotlin][Client] Option to remove Response<> wrapper in operation return types

Open
#15,491 11 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

Enhancement: Feature
Dominant language
Java
Stars
26.8k
Forks
7.7k
PR merge metrics
PR metrics pending

Description

Currently if you use Coroutines (suspend modifier), your generated API functions will look like this:

@GET("users/{id}")
suspend fun user(@Path("id") id: Long): Response<User>

However there is another way to define the return type of the endpoint. You can omit the Response<> wrapper, and just return the User, like this:

@GET("users/{id}")
suspend fun user(@Path("id") id: Long): User

This is described here in the Retrofit documentation.

It would be great if OpenAPI generator offer this as well. It could be controlled by a CLI option, and it could generated the current Response<User> form by default.

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 reviewing the Kotlin coroutine client generation path and how generated operation return types are currently formed. Compare the existing Response form with Retrofit's documented plain User form, then identify where a CLI option and its default would be represented. Done means the option produces the requested return type while preserving the current Response behavior by default.

Written by the indexing model from the issue text.

Assessment

Tech stack
kotlin
Domain
api, tooling
Issue type
Feature
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.