Ktorfit icon indicating copy to clipboard operation
Ktorfit copied to clipboard

@RequestType from List to Non List will produce wrong code

Open tlevavasseur-decathlon opened this issue 7 months ago • 0 comments

Ktorfit version

2.5.2

What happened and how can we reproduce this issue?

If you try to convert a List into a non Iterable type then the generated code is invalid

@Query("data") @RequestType(String::class) data: List<Something>,

will produce

val data: String = _helper.convertParameterType(data,data::class,String::class)
...
data?.filterNotNull()?.forEach { parameter("data", "$it") }

which doesn't compile because data is no more a List.

What did you expect to happen?

the requestType should be used when determining if the type is Iterable, and in this case it's not anymore, the generated code should be :

data?.let{ parameter("data", "$it") }

Is there anything else we need to know about?

No response

tlevavasseur-decathlon avatar Jun 17 '25 20:06 tlevavasseur-decathlon