Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix compile issue with RequestType and multiple parameters #627

Merged
merged 3 commits into from
Aug 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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