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.61k stars 42 forks source link

Generated classes do not propagate opt-in ExperimentalUuidApi #666

Closed markocic closed 2 weeks ago

markocic commented 2 months ago

Ktorfit version

2.1.0

What happened and how can we reproduce this issue?

I am using new Uuid API that was shipped with kotlin 2.0.20 and have an interface defining Stores API implemented like this:

import kotlin.uuid.ExperimentalUuidApi
import kotlin.uuid.Uuid

@OptIn(ExperimentalUuidApi::class)
interface StoresApi {

    @GET("v1/stores")
    suspend fun getStores(
        @Query("workspaceId") workspaceId: Uuid,
        @Query("after") after: Instant? = null,
    ): PagedDataResponse<StoreApiModel>

    @GET("v1/stores/{storeId}")
    suspend fun getStoreById(
        @Path("storeId") storeId: Uuid,
    ): ReceiptResponse

}

Interface written like this will fail at build time with a message:

android/business/api/_StoresApiImpl.kt:35:47 This declaration needs opt-in. Its usage must be marked with @kotlin.uuid.ExperimentalUuidApi or @OptIn(kotlin.uuid.ExperimentalUuidApi::class)

What did you expect to happen?

I expected build to be successful and for Ktorfit to propagate @OptIn(ExperimentalUuidApi::class) annotation to generated classes.

Is there anything else we need to know about?

No response

Foso commented 2 weeks ago

It's fixed with Ktorfit 2.2.0