Skip to content

Fix code generation for RequestType annotated lists - #1072

Open
JanTie wants to merge 1 commit into
Foso:masterfrom
JanTie:bugfix/fix-request-type-for-list-parameters
Open

Fix code generation for RequestType annotated lists#1072
JanTie wants to merge 1 commit into
Foso:masterfrom
JanTie:bugfix/fix-request-type-for-list-parameters

Conversation

@JanTie

@JanTie JanTie commented Jun 2, 2026

Copy link
Copy Markdown

Problem

Using a @RequestType annotation on List/Array parameters was not supported properly as the generated code treat the parameter builder as iterable, no matter what the type was actually mapped to. So for example the following code would previously cause ksp to generate non-compiling code:

interface MyDataSource {
    @GET
    suspend fun getData(
        @Url url: String,
        @Query("someFilterData") @RequestType(String::class) someFilterData: List<Filters>
    ): MyResponse
}

In this case the backend is supposed to work with a comma separated and html-encoded value for someFilterData. A converter factory should take care of that.

However, currently the generated code produces the following line

someFilterData?.filterNotNull()?.forEach { parameter("someFilterData", "$it") }

which does not compile, as the parameter is already expected to be a String at this point.

Change

The proposed change now no longer relies on the initial datatype to determine how the parameters are added to the request. Instead the actual mapped type causes the code generation to decide which approach is the correct one.

Also added an Example implementation of the stated ConverterFactory to the demo project

@JanTie
JanTie requested a review from Foso as a code owner June 2, 2026 12:51
@github-actions github-actions Bot added documentation Improvements or additions to documentation ktorfit-ksp build sandbox labels Jun 2, 2026
@JanTie
JanTie force-pushed the bugfix/fix-request-type-for-list-parameters branch 2 times, most recently from 7f5a7cb to 19e11bb Compare June 4, 2026 07:22
@JanTie
JanTie force-pushed the bugfix/fix-request-type-for-list-parameters branch from 19e11bb to b9095d4 Compare June 9, 2026 13:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

build documentation Improvements or additions to documentation ktorfit-ksp sandbox

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant