From ba0d6ca9fb20bb20a61ab0fb9274863e66bdce04 Mon Sep 17 00:00:00 2001 From: Jens Klingenberg Date: Sun, 14 May 2023 18:55:15 +0200 Subject: [PATCH] release v1.3.0 (#295) * release v1.3.0 --- README.md | 3 ++- docs/CHANGELOG.md | 23 +++++++++++++++++++ .../AndroidOnlyExample/app/build.gradle.kts | 2 +- example/AndroidOnlyExample/build.gradle | 2 +- .../shared/build.gradle.kts | 4 ++-- gradle/libs.versions.toml | 6 ++--- .../reqBuilderExtension/UrlCodeGeneration.kt | 3 ++- .../de/jensklingenberg/ktorfit/UrlTest.kt | 4 ++-- .../requestData/UrlArgumentTextKtTest.kt | 2 +- 9 files changed, 37 insertions(+), 12 deletions(-) diff --git a/README.md b/README.md index fdaf6c7f4..4a3adae20 100644 --- a/README.md +++ b/README.md @@ -24,7 +24,8 @@ Please see the documentation at [https://foso.github.io/Ktorfit/](https://foso.g | Version | Kotlin | KSP | Ktor | |--------------|:----------:|:----------:|:---------:| -| **_latest_** | **1.8.20** | **1.0.10** | **2.3.0** | +| **_latest_** | **1.8.20** | **1.0.11** | **2.3.0** | +| **_1.2.0_** | **1.8.20** | **1.0.10** | **2.3.0** | | **_1.1.0_** | **1.8.20** | **1.0.10** | **2.2.4** | # Release diff --git a/docs/CHANGELOG.md b/docs/CHANGELOG.md index e724e215c..c13fc2510 100644 --- a/docs/CHANGELOG.md +++ b/docs/CHANGELOG.md @@ -15,12 +15,35 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. ### Removed +### Fixed + +### Security + +### Bumped + +1.3.0 - 2023-05-14 +======================================== + +### Added + +### Changed +* Optimized generated code, the generated code that is used for a request will + now directly set the Ktor code instead of delegating it to a Ktorfit class. This will + make the code easier to understand. + +* KSP version 1.0.11 is now needed + +### Deprecated + +### Removed + ### Fixed [Bug]: IllegalArgumentException with Custom Http Annotation #274 ### Security ### Bumped +KSP version to 1.0.11 1.2.0 - 2023-05-05 ======================================== diff --git a/example/AndroidOnlyExample/app/build.gradle.kts b/example/AndroidOnlyExample/app/build.gradle.kts index 81607c63c..7d90e044f 100644 --- a/example/AndroidOnlyExample/app/build.gradle.kts +++ b/example/AndroidOnlyExample/app/build.gradle.kts @@ -6,7 +6,7 @@ plugins { id ("de.jensklingenberg.ktorfit") version "1.0.0" } -val ktorfit = "1.2.0" +val ktorfit = "1.3.0" configure { version = ktorfit diff --git a/example/AndroidOnlyExample/build.gradle b/example/AndroidOnlyExample/build.gradle index ae1fe627b..5ca376c6e 100644 --- a/example/AndroidOnlyExample/build.gradle +++ b/example/AndroidOnlyExample/build.gradle @@ -1,6 +1,6 @@ // Top-level build file where you can add configuration options common to all sub-projects/modules. plugins { - id 'com.android.application' version '8.0.1' apply false + id 'com.android.application' version '8.0.0-alpha09' apply false id 'com.android.library' version '8.0.0-alpha09' apply false id 'org.jetbrains.kotlin.android' version '1.8.20' apply false } \ No newline at end of file diff --git a/example/MultiplatformExample/shared/build.gradle.kts b/example/MultiplatformExample/shared/build.gradle.kts index ee201d75c..0f4de3fb6 100644 --- a/example/MultiplatformExample/shared/build.gradle.kts +++ b/example/MultiplatformExample/shared/build.gradle.kts @@ -2,14 +2,14 @@ plugins { kotlin("multiplatform") kotlin("native.cocoapods") id("com.android.library") - id("com.google.devtools.ksp") version "1.8.20-1.0.10" + id("com.google.devtools.ksp") version "1.8.20-1.0.11" id("kotlinx-serialization") id("de.jensklingenberg.ktorfit") version "1.0.0" } version = "1.0" val ktorVersion = "2.3.0" -val ktorfitVersion = "1.2.0" +val ktorfitVersion = "1.3.0" configure { version = ktorfitVersion diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index d9ed4e994..860eca3af 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -5,9 +5,9 @@ detekt = "1.22.0" kctfork = "0.2.1" kotlin = "1.8.20" kotlinPoet = "1.13.2" -kspVersion = "1.8.20-1.0.10" -ktorfit = "1.2.0" -ktorfit-lib = "1.1.0" +kspVersion = "1.8.20-1.0.11" +ktorfit = "1.3.0" +ktorfit-lib = "1.3.0" ktorVersion = "2.3.0" dokkaVersion = "1.8.10" diff --git a/ktorfit-ksp/src/main/kotlin/de/jensklingenberg/ktorfit/reqBuilderExtension/UrlCodeGeneration.kt b/ktorfit-ksp/src/main/kotlin/de/jensklingenberg/ktorfit/reqBuilderExtension/UrlCodeGeneration.kt index 51d01a7e8..6a3bd17bd 100644 --- a/ktorfit-ksp/src/main/kotlin/de/jensklingenberg/ktorfit/reqBuilderExtension/UrlCodeGeneration.kt +++ b/ktorfit-ksp/src/main/kotlin/de/jensklingenberg/ktorfit/reqBuilderExtension/UrlCodeGeneration.kt @@ -25,12 +25,13 @@ fun getUrlCode(params: List, methodAnnotation: HttpMethodAnnotati params.filter { it.hasAnnotation() }.forEach { parameterData -> val paramName = parameterData.name val pathAnnotation = parameterData.findAnnotationOrNull()!! + val pathEncoded = if (!pathAnnotation.encoded) { ".encodeURLPath()" } else { "" } - urlPath = urlPath.replace("{$paramName}", "\${\"\$${paramName}\"$pathEncoded}") + urlPath = urlPath.replace("{${pathAnnotation.value}}", "\${\"\$${paramName}\"$pathEncoded}") } diff --git a/ktorfit-ksp/src/test/kotlin/de/jensklingenberg/ktorfit/UrlTest.kt b/ktorfit-ksp/src/test/kotlin/de/jensklingenberg/ktorfit/UrlTest.kt index 993ed8611..093cd5b0a 100644 --- a/ktorfit-ksp/src/test/kotlin/de/jensklingenberg/ktorfit/UrlTest.kt +++ b/ktorfit-ksp/src/test/kotlin/de/jensklingenberg/ktorfit/UrlTest.kt @@ -53,14 +53,14 @@ import de.jensklingenberg.ktorfit.http.Path interface TestService { @GET("user/{id}") - suspend fun test(@Path("id") id: String): String + suspend fun test(@Path("id") userId: String): String } """ ) - val expectedFunctionText = """url(ktorfitClient.baseUrl + "user/ä{"äid".encodeURLPath()}") """.replace("ä","$") + val expectedFunctionText = """url(ktorfitClient.baseUrl + "user/ä{"äuserId".encodeURLPath()}")""".replace("ä","$") val compilation = getCompilation(listOf(source)) val result = compilation.compile() diff --git a/ktorfit-ksp/src/test/kotlin/de/jensklingenberg/ktorfit/requestData/UrlArgumentTextKtTest.kt b/ktorfit-ksp/src/test/kotlin/de/jensklingenberg/ktorfit/requestData/UrlArgumentTextKtTest.kt index 8f9c83a10..9342a2fd4 100644 --- a/ktorfit-ksp/src/test/kotlin/de/jensklingenberg/ktorfit/requestData/UrlArgumentTextKtTest.kt +++ b/ktorfit-ksp/src/test/kotlin/de/jensklingenberg/ktorfit/requestData/UrlArgumentTextKtTest.kt @@ -55,7 +55,7 @@ class UrlArgumentTextKtTest { val parameterData = ParameterData("test1", ReturnTypeData("String", "kotlin.String", null), annotations = listOf(path)) val params = listOf(parameterData) - val text = getUrlCode(params,HttpMethodAnnotation("user/{test1}",HttpMethod.GET)) + val text = getUrlCode(params,HttpMethodAnnotation("user/{testValue}",HttpMethod.GET)) Assert.assertEquals("""url(ktorfitClient.baseUrl + "user/ä{"ätest1".encodeURLPath()}")""".replace("ä","$"), text) } } \ No newline at end of file