Foso / Ktorfit

HTTP client generator / KSP plugin for Kotlin Multiplatform (Android, iOS, Js, Jvm, Native, WasmJs)) using KSP and Ktor clients inspired by Retrofit https://foso.github.io/Ktorfit
https://foso.github.io/Ktorfit
Apache License 2.0
1.6k stars 43 forks source link

Unresolved reference setBody in generated API implementations #726

Closed padmalcom closed 1 week ago

padmalcom commented 2 weeks ago

Ktorfit version

2.1.0

What happened and how can we reproduce this issue?

When building my multiplatform project, the implementation of the following API lacks the import 'import io.ktor.client.request.setBody'.

interface FileApi {
    @GET(Endpoints.FILE_BY_ID)
    suspend fun downloadFile(
        @Path("fileId") fileId: String
    ): Response<ByteArray>

    @Multipart
    @POST(Endpoints.FILES)
    @Headers("$HEADER_NO_BODY_LOGGING: true")
    suspend fun uploadFile(
        @Part file: PartData
    ): Response<Boolean>
}

What did you expect to happen?

I'd expect ktorfit to add the missing import.

Is there anything else we need to know about?

We are grateful for your effort with this nice library.

Foso commented 1 week ago

Hi @padmalcom , thank you for the bug report! I had not noticed the bug because i always had a some other function in the same file where i used @Body and that added the import

padmalcom commented 1 week ago

Hi @Foso, thank you for your fast reply. So for the time waiting I add a dummy interface adding a @Body annotation to get the required import.

yurii-shcherbiuk commented 1 week ago

@Foso ksp 1.0.27

Знімок екрана 2024-11-09 о 18 50 24
Foso commented 1 week ago

@yurii-shcherbiuk Thank you for the information! The imports are now fixed with Ktorfit 2.2.0