diff --git a/docs/CHANGELOG.md b/docs/CHANGELOG.md index c8cd7b166..7529d2707 100644 --- a/docs/CHANGELOG.md +++ b/docs/CHANGELOG.md @@ -8,6 +8,7 @@ Note: This project needs KSP to work and every new Ktorfit with an update of the But there is no intent to bump the Ktorfit major version for every KSP update. # Unreleased +## Added - Provide option to not use the compiler plugin #764 You can now set the Kotlin version for the compiler plugin. By default, it will use the Kotlin version of the project. You can set it to "-" to disable the plugin. @@ -20,6 +21,9 @@ ktorfit{ } ``` +## Fixed +- @Headers annotation produces unexpected newline in generated code by ksp plugin #752 + # [2.2.0]() * Supported Kotlin version: 2.0.0; 2.0.10; 2.0.20, 2.1.0-Beta1; 2.0.21-RC, 2.0.21, 2.1.0-RC, 2.1.0-RC2, 2.1.0, 2.1.10 * Supported KSP version: 1.0.27, 1.0.28, 1.0.29 diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 9e3074d26..3f16c27ad 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -7,7 +7,7 @@ detekt = "1.23.7" junit = "4.13.2" kctfork = "0.7.0" kotlin = "2.1.10" -kotlinPoet = "1.18.1" +kotlinPoet = "2.0.0" kspVersion = "2.1.10-1.0.29" groupId = "de.jensklingenberg.ktorfit" diff --git a/ktorfit-ksp/src/main/kotlin/de/jensklingenberg/ktorfit/model/annotations/ParameterAnnotation.kt b/ktorfit-ksp/src/main/kotlin/de/jensklingenberg/ktorfit/model/annotations/ParameterAnnotation.kt index 2faa94ec3..825b9584e 100644 --- a/ktorfit-ksp/src/main/kotlin/de/jensklingenberg/ktorfit/model/annotations/ParameterAnnotation.kt +++ b/ktorfit-ksp/src/main/kotlin/de/jensklingenberg/ktorfit/model/annotations/ParameterAnnotation.kt @@ -128,7 +128,7 @@ fun KSValueParameter.getParamAnnotationList(logger: KSPLogger): List entry.value?.let{ parameter(entry.key, \"\${entry.value}\") }\n" + - " }\n" + - " testQueryMap2?.forEach { entry -> entry.value?.let{ encodedParameters.append(entry.key,\n" + - " \"\${entry.value}\") } }\n" + - " }" + " takeFrom(_ktorfit.baseUrl + \"posts\")\n" + + " testQueryMap?.forEach { entry -> entry.value?.let{ parameter(entry.key, \"\${entry.value}\") } }\n" + + " testQueryMap2?.forEach { entry -> entry.value?.let{ encodedParameters.append(entry.key, \"\${entry.value}\") } }\n" + + " }" val compilation = getCompilation(listOf(source)) val result = compilation.compile() @@ -186,12 +184,11 @@ fun example(@Query("name") testQuery: String, @QueryName testQueryName: String, val expectedQueriesArgumentText = "url{\n" + - " takeFrom(_ktorfit.baseUrl + \"posts\")\n" + - " testQuery?.let{ parameter(\"name\", \"\$it\") }\n" + - " parameters.appendAll(\"\$testQueryName\", emptyList())\n" + - " name?.forEach { entry -> entry.value?.let{ encodedParameters.append(entry.key,\n" + - " \"\${entry.value}\") } }\n" + - " }" + " takeFrom(_ktorfit.baseUrl + \"posts\")\n" + + " testQuery?.let{ parameter(\"name\", \"\$it\") }\n" + + " parameters.appendAll(\"\$testQueryName\", emptyList())\n" + + " name?.forEach { entry -> entry.value?.let{ encodedParameters.append(entry.key, \"\${entry.value}\") } }\n" + + " }" val compilation = getCompilation(listOf(source)) val result = compilation.compile() diff --git a/sandbox/src/commonMain/kotlin/com/example/model/ExampleApi.kt b/sandbox/src/commonMain/kotlin/com/example/model/ExampleApi.kt index ab95aac6b..6e25dff55 100644 --- a/sandbox/src/commonMain/kotlin/com/example/model/ExampleApi.kt +++ b/sandbox/src/commonMain/kotlin/com/example/model/ExampleApi.kt @@ -2,8 +2,11 @@ package com.example.model import de.jensklingenberg.ktorfit.Response import de.jensklingenberg.ktorfit.http.GET +import de.jensklingenberg.ktorfit.http.Headers interface ExampleApi { + + @Headers("User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/132.0.0.0 Safari/537.36 Edg/132.0.0.0") @GET("example.json") suspend fun getUser(): Response