Package-level declarations

Core Annotations

This section documents the core annotations used to define options and how the compiler interprets them. These annotations control how Ktorgen scans interfaces, generates client factories, and connects them to Ktor’s HTTP client.

More information, see Core Annotations.

Types

Link copied to clipboard

Each generated class, function, and files is annotated with this to identify them if they need to be excluded, for instance, by static analysis tools.

Link copied to clipboard
@Target(allowedTargets = [AnnotationTarget.CLASS])
annotation class KtorGen(val name: String = KTORGEN_DEFAULT_NAME, val generate: Boolean = true, @Language(value = "http-url-reference") val basePath: String = "", val generateTopLevelFunction: Boolean = true, val generateCompanionExtFunction: Boolean = false, val generateHttpClientExtension: Boolean = false, val propagateAnnotations: Boolean = true, val annotations: Array<KClass<out Annotation>> = [], val optInAnnotations: Array<KClass<out Annotation>> = [], val functionAnnotations: Array<KClass<out Annotation>> = [], val visibilityModifier: String = KTORGEN_DEFAULT_NAME, val classVisibilityModifier: String = KTORGEN_DEFAULT_NAME, val constructorVisibilityModifier: String = KTORGEN_DEFAULT_NAME, val functionVisibilityModifier: String = KTORGEN_DEFAULT_NAME, val customFileHeader: String = KTORGEN_DEFAULT_NAME, val customClassHeader: String = "")

Indicates that an interface should be used for Ktor Client code generation.

Link copied to clipboard
annotation class KtorGenExperimental

Experimental API, the compiler can omit the property or annotation, or generated code has errors.

Link copied to clipboard
@Target(allowedTargets = [AnnotationTarget.FUNCTION])
annotation class KtorGenFunction(val generate: Boolean = true, val propagateAnnotations: Boolean = true, val annotations: Array<KClass<out Annotation>> = [], val optInAnnotations: Array<KClass<out Annotation>> = [], val customHeader: String = "")

Indicates that a method within a @KtorGen-annotated interface should participate in code generation.

Link copied to clipboard

An annotation used to mark an expect factory function for multi-platform support in KSP running on each platform.