Skip to content

Commit

Permalink
Fix compile issue with RequestType and multiple parameters (#627)
Browse files Browse the repository at this point in the history
  • Loading branch information
Foso authored Aug 8, 2024
1 parent b5117cd commit 19fc43f
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 3 deletions.
5 changes: 5 additions & 0 deletions docs/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,11 @@ Unreleased
- #594 Endpoint with types from other module
- #591 Ktorfit plugin doesn't include correct generate source if build directory changes #591
- Build with Ktor 2.3.12
- #621 RequestConverter causing compile error

ktorfit-ksp-2.0.0-1.0.24 - 2024-06-08
========================================
- Build with KSP 1.0.24

ktorfit-ksp-2.0.0-1.0.23 - 2024-07-14
========================================
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,16 @@ fun FunSpec.Builder.addRequestConverterText(parameterDataList: List<ParameterDat
if (parameterDataList.any { it.hasAnnotation<RequestType>() }) {
parameterDataList.map { parameter ->
val requestTypeClassName =
parameter.annotations.filterIsInstance<RequestType>().first().requestType.toClassName()
parameter.annotations
.filterIsInstance<RequestType>()
.firstOrNull()
?.requestType
?.toClassName()
if (parameter.hasAnnotation<RequestType>()) {
this.addStatement(
"val %L: %T = %L.convertParameterType(%L,%L::class,%T::class)",
parameter.name,
requestTypeClassName,
requestTypeClassName!!,
converterHelper.objectName,
parameter.name,
parameter.name,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import de.jensklingenberg.ktorfit.http.*
interface TestService {
@GET("posts/{postId}/comments")
suspend fun test(@RequestType(Int::class) @Path("postId") postId: String): String
suspend fun test(@RequestType(Int::class) @Path("postId") postId: String, @Query("postId") testQuery: String): String
}
""",
)
Expand Down

0 comments on commit 19fc43f

Please sign in to comment.