Ktor Gen Function
Indicates that a method within a @KtorGen
-annotated interface should participate in code generation.
This annotation provides fine-grained control over how annotations from the original interface method are handled and propagated to the generated implementation.
It is useful when you want to selectively propagate certain annotations from the original method, such as @JvmSynthetic
, @Deprecated
, or annotations marked with @RequiresOptIn
, to the generated method.
Example
interface UserRoutes {
@GET("/users/{id}")
@KtorGenFunction(
propagateAnnotations = true, // JvmSynthetic is propagated as-is
annotations = [CustomAnnotation::class], // required have empty constructor, e.g. @JvmOverloads
optInAnnotations = [ExperimentalApi::class], // means = don't propagate, prefer optIn this
)
@JvmSynthetic
@ExperimentalApi
suspend fun getUser(@Path id: Int): User
}
See also
Properties
KtorGenExperimental Additional annotations or only these annotations to propagate as-is from the interface method to the generated implementation.
Custom KDoc comment for the generated implementation class.
KtorGenExperimental Opt-in annotations that should be propagated to generated method, need be marked with @RequiresOptIn or @SubclassOptInRequired, otherwise the generated code will not compile because requirements of @OptIn.
KtorGenExperimental Indicate if annotations from the source method should be copied to the generated method.