All important changes of this project must be documented in this file.
The format is based on Keep a Changelog and this project orients towards Semantic Versioning. Note: This project needs KSP to work and every new Ktorfit with an update of the KSP version is technically a breaking change. But there is no intent to bump the Ktorfit major version for every KSP update.
- 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
- Supported KSP version: 1.0.27, 1.0.28, 1.0.29
- Ktor version: 3.0.1
- Ktorfit is now using Ktor 3.0.1 as a default. The extra versions with "-ktor3" will not be updated anymore.
- This also means that now wasmJs is supported by default.
-
Inheritance problem #663 See https://foso.github.io/Ktorfit/generation/#nodelegation
-
Generated classes do not propagate opt-in ExperimentalUuidApi 666 OptIn annotations on interfaces and functions will now be propagated to the generated classes.
-
Fixed documentation for converters to match the current version.
-
Unresolved reference setBody in generated API implementations #726
-
[Android] App crashes if not using Ktor platform client #720
- 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
- Supported KSP version: 1.0.24; 1.0.25, 1.0.26, 1.0.27
- Ktor version: 2.3.12; 3.0.0
- documentation page for known issues
- Allow Http Delete with Body #647
- By default, nullable response types will not throw an exception. You can now override this behavior by adding the DontSwallowExceptionsConverterFactory or your own ConverterFactory to the converterFactories. #618
- Task with path 'kspCommonMainKotlinMetadata' not found in project #593
- Ktorfit Gradle Plugin not compatible with Android Multiplatform Library plugin #638
The "normal" dependencies will stay on Ktor 2.x till 3.0 is stable. But here are versions that you can use when want to use Ktor3 and WasmJs
de.jensklingenberg.ktorfit:ktorfit-lib-light-ktor-3.0.0:2.1.0
de.jensklingenberg.ktorfit:ktorfit-lib-ktor-3.0.0:2.1.0
de.jensklingenberg.ktorfit:ktorfit-converters-flow-ktor-3.0.0:2.1.0
de.jensklingenberg.ktorfit:ktorfit-converters-call-ktor-3.0.0:2.1.0
de.jensklingenberg.ktorfit:ktorfit-converters-response-ktor-3.0.0:2.1.0
- Supported Kotlin version: 2.0.0; 2.0.10; 2.0.20
- Supported KSP version: 1.0.24
- Ktor version: 2.3.12
- Endpoint with types from other module #594
- Ktorfit plugin doesn't include correct generate source if build directory changes #591
- RequestConverter causing compile error #621
- Build with Ktor 2.3.12
- 2.0.1: The annotations are now also available for WasmJs
- Kotlin 2.0.0: 2.0.1-2.0.0 - 2024-08-08
- Kotlin 2.0.10: 2.0.1-2.0.10 - 2024-08-10
- Kotlin 2.0.20-RC: 2.0.1-2.0.20-RC - 2024-08-13
- Kotlin 2.0.20-RC2: 2.0.1-2.0.20-RC2 - 2024-08-13
- Kotlin 2.0.20: 2.0.1-2.0.20 - 2024-08-23
- KSP 1.0.24: ktorfit-ksp-2.0.1-1.0.24 - 2024-08-08
The "normal" dependencies will stay on Ktor 2.x till 3.0 is stable. But here are versions that you can use when want to use Ktor3 and WasmJs
- Build with KSP 1.0.24
- Build with KSP 1.0.23
- Build with KSP 1.0.22
- Build with KSP 1.0.21, Kotlin 2.0.0, Ktor 2.3.11
- The needed dependencies for Ktorfit KSP processor are now included in the Ktorfit Gradle plugin. You can remove the ksp() block from your build.gradle.kts file. You still need to apply the KSP plugin.
plugins {
id("com.google.devtools.ksp") version "CURRENT_KSP_VERSION"
id("de.jensklingenberg.ktorfit") version "2.0.0"
}
See the installation guide for more information: https://foso.github.io/Ktorfit/installation/
- The code that is generated by KSP is now accessible from the module where the interface is defined. That means code from commonMain can now find the generated code. Generated code from the platform specific code is still only available from the specific modules.
- The create function is now deprecated. The reason for that is that it is relying on a compiler plugin to work. This can lead to compile errors when the class can't be found. The plan is to get rid of the plugin. When your project is configured correct, the autocompletion should show an extension function create followed by the name of the interface. This function will not trigger the compiler plugin
val api = ktorfit.create<ExampleApi>()
replace with:
val api = ktorfit.createExampleApi()
The deprecated code got removed. This will simplify the codebase and make it easier to maintain. When you haven't used the deprecated converters, there is not much you need to change. The dependencies for the converters that were previously auto added now need to be added manually. See the migration guide for more information: https://foso.github.io/Ktorfit/migration/#from-2-to-200
- QualifiedTypeName in Ktorfit
In the previous versions of Ktorfit, the qualifiedTypename
was always generated in the code. This was used in the TypeData.createTypeData()
function to provide a fully qualified type name for the data type being used.
val _typeData = TypeData.createTypeData(
typeInfo = typeInfo<Call<People>>(),
qualifiedTypename = "de.jensklingenberg.ktorfit.Call<com.example.model.People>"
)
In the new version of Ktorfit, this behavior has been changed. Now, by default, Ktorfit will keep qualifiedTypename
for TypeData
in the generated code empty. This means that the qualifiedTypename
will not be automatically generated.
val _typeData = TypeData.createTypeData(
typeInfo = typeInfo<Call<People>>(),
)
However, if you want to keep the old behavior and generate qualifiedTypename
, you can set it in the Ktorfit config generateQualifiedTypeName
to true
in your build.gradle.kts
file.
ktorfit {
generateQualifiedTypeName = true
}
This change was made to provide more flexibility and control to the developers over the generated code. Please update your code accordingly if you were relying on the automatic generation of qualifiedTypename
.
- Fixes #548
- Build with KSP 1.0.20, Kotlin 2.0.0-RC3, Ktor 2.3.11
- Optimize code generation
- Fixes #548
The deprecated code got removed. This will simplify the codebase and make it easier to maintain. When you haven't used the deprecated converters, there is not much you need to change. Some converters that were previously auto applied now need to be added manually. See the migration guide for more information: https://foso.github.io/Ktorfit/migration/#from-2-to-200
In the previous versions of Ktorfit, the qualifiedTypename
was always generated in the code. This was used in the TypeData.createTypeData()
function to provide a fully qualified type name for the data type being used.
val _typeData = TypeData.createTypeData(
typeInfo = typeInfo<Call<People>>(),
qualifiedTypename = "de.jensklingenberg.ktorfit.Call<com.example.model.People>"
)
In the new version of Ktorfit, this behavior has been changed. Now, by default, Ktorfit will keep qualifiedTypename
for TypeData
in the generated code empty. This means that the qualifiedTypename
will not be automatically generated.
val _typeData = TypeData.createTypeData(
typeInfo = typeInfo<Call<People>>(),
)
However, if you want to keep the old behavior and generate qualifiedTypename
, you can set a KSP argument Ktorfit_QualifiedTypeName
to true
in your build.gradle.kts
file.
ksp {
arg("Ktorfit_QualifiedTypeName", "true")
}
This change was made to provide more flexibility and control to the developers over the generated code. Please update your code accordingly if you were relying on the automatic generation of qualifiedTypename
.
- Build with KSP 1.0.20, Kotlin 2.0.0-RC1, Ktor 2.3.10
- Build with KSP 1.0.20, Kotlin 1.9.23, Ktor 2.3.10
- Compatible with KSP 1.0.16 and Kotlin 1.9.22
- Fix compile errors #505 #496
Compatible with KSP 1.0.15 and Kotlin 1.9.21
- KSP 1.0.15 required
- Upgrade dependencies: Ktor 2.3.6
- fix compile errors because of missing import #490 #486
- Using @FieldMap generates uncompiled code due to missing import #479
Compatible with KSP 1.0.14 and Kotlin 1.9.20
- LinuxArm64 support #475
- KSP 1.0.14 required
- Optimized code generation
Compatible with KSP 1.0.13 and Kotlin 1.9.10/1.9.20-RC
When you are still using the Ktorfit Gradle plugin in version 1.0.0, please also update this to 1.9.1
- Add Tag annotation https://foso.github.io/Ktorfit/requests/#tag
- The generated code will not produce warnings anymore
Compatible with KSP 1.0.13 and Kotlin 1.9.10/1.9.20-Beta2
- Allow nullable body type #424
- Use @Path parameter name as default value #426
- Use @Query parameter name as default value #428
- Use @Field parameter name as default value #430
- You can now also get exceptions like NetworkException with SuspendResponseConverter.#389
- Deprecated the
convert
function in theSuspendResponseConverter
interface See: https://foso.github.io/Ktorfit/migration/#from-170-to-181
! When you still use the deprecated converters because there are use cases which you can't do with the converter factories, please write a GitHub Issue. The deprecated converters will be removed in one of the upcoming versions
Skip this version, it had an issue with Kotlin 1.9.20
Version of 1.7.0 that is compatible with Kotlin 1.9.20-Beta2
From now on with every Ktorfit release there will also be a Gradle plugin with the same version. That means that drop you can drop the Gradle extension block where you previously set the version number and just bump the number of the Gradle plugin. https://foso.github.io/Ktorfit/installation/
plugins {
id("de.jensklingenberg.ktorfit") version "1.7.0"
}
- Added a compiler type checks if the type used for the create function is an interface
- Upgrade dependencies: Ktor 2.3.4
- KSP version 1.9.10-1.0.13 is now required
- Upgrade dependencies: Ktor 2.3.3
- KSP version 1.9.0-1.0.13 is now needed
- Upgrade dependencies: Ktor 2.3.2
#372 Crash with Xiaomi on create Ktorfit.Builder by @princeparadoxes
#323 Code generation issue for @Multipart / @FormUrlEncoded by @Ph1ll1pp
- Upgrade dependencies: Ktor 2.3.1
#236 Parsing error for list/array
- #85 Added a Response class that can be used as a wrapper around the API Response, the converter for it is automatically applied. thx to @vovahost, @DATL4G
e.g.
interface ExampleApi{
suspend fun getUser(): Response<User>
}
val user = userKtorfit.create<ExampleApi>().getUser()
if(user.isSuccessful){
user.body()
}else{
user.errorBody()
}
-
Ktorfit is now using converters factories to apply the converters, similar to Retrofit see more here https://foso.github.io/Ktorfit/converters/converters/
-
TypeData now has a field "typeInfo" can be used to convert the Ktor HttpResponse body to the wanted type
-
CallConverterFactory for replacement of CallResponseConverter
-
FlowConverterFactory for replacement of FlowResponseConverter
-
Added support for targets: macosArm64, tvosArm64, tvosX64, tvosSimulatorArm64, watchosSimulatorArm64 #315
- Upgrade dependencies: Kotlin 1.8.21
- ResponseConverter, use Converter.ResponseConverter instead
- SuspendResponseConverter, use Converter.SuspendResponseConverter instead
- RequestConverter, use Converter.RequestParameterConverter instead
- See also: https://foso.github.io/Ktorfit/converters/migration/
-
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
[Bug]: IllegalArgumentException with Custom Http Annotation #274
KSP version to 1.0.11
Now based on Ktor 2.3.0
From now on there are two versions of the ktorfit-lib.
"de.jensklingenberg.ktorfit:ktorfit-lib" will stay like before and add the platform client dependencies for the clients.
"de.jensklingenberg.ktorfit:ktorfit-lib-light" this will only add the client core dependency and not the platform dependencies for the clients. This will give you more control over the used clients, but you have to add them yourself. https://ktor.io/docs/http-client-engines.html Everything else is the same as "ktorfit-lib"
- Kotlin version 1.8.20 is now needed
- KSP version 1.8.20-1.0.10 is now needed
- Kotlin to 1.8.20
- KSP version to 1.8.20-1.0.10
From now on there are two versions of the ktorfit-lib.
"de.jensklingenberg.ktorfit:ktorfit-lib" will stay like before and add the platform client dependencies for the clients.
"de.jensklingenberg.ktorfit:ktorfit-lib-light" this will only add the client core dependency and not the platform dependencies for the clients. This will give you more control over the used clients, but you have to add them yourself. https://ktor.io/docs/http-client-engines.html Everything else is the same as "ktorfit-lib"
[Bug]: Post request body serialization doesn't work #202
This project is now following semver
- internal optimizations
- throw compile error when generated class can not be found
- Timeout throws exception outside of scope of SuspendResponseConverter #127
- Fix broken/outdated docs link (#140) by @T-Spoon
- based on Ktor 2.2.4
NEW:
- You can now disable the check if the baseUrl ends with a /
Ktorfit.Builder().baseUrl(testBaseUrl, checkUrl = false).build()
🐛 Bugs fixed
- Fixed Ktorfit breaking incremental compilation #110
⬆️ Deps updates
- based on Ktor 2.2.3
💥 Breaking changes:
- Ktorfit now needs an additional gradle plugin. This will solve several issues with multi-module projects.
Add this plugin:
plugins {
id "de.jensklingenberg.ktorfit" version "1.0.0"
}
NEW:
- interfaces can now be internal
🐛 Bugs fixed
- Ktorfit multiple module support #92
- Add support for 'internal' parameter type #13
- Duplicate class KtorfitExtKt found in modules moduleA and moduleB #86
- Android overload resolution ambiguity #64
- Form data is double encoded #95
⬆️ Deps updates
- based on Ktor 2.2.2
- Kotlin 1.8.0
- KSP 1.8.0-1.0.8
- update Android TargetSdk to 33
NEW:
-
Field parameters can now be nullable, null values will be ignored in requests
-
Add option to turn of error checking
ksp { arg("Ktorfit_Errors", "1") }
You can set it in your build.gradle.kts file,
0: Turn off all Ktorfit related error checking
1: Check for errors
2: Turn errors into warnings
-
Added RequestConverter support #84
⬆️ Deps updates
- based on Ktor 2.1.3
- Kotlin 1.7.21
- KSP 1.0.8
- update Android TargetSdk to 33
🐛 Bugs fixed
- FlowResponseConverter #81
- build(deps): bump logback-classic from 1.4.0 to 1.4.3 by @dependabot in #74
- Foso/revert converters changes by @Foso in #76
- 67 add nullable field parameters support by @Foso in #80
- fix: FlowResponseConverter by @Foso in #81
- Added RequestConverter support by @DATL4G in #84
- feat: add option to turn off error checking #77 by @Foso in #88
Full Changelog: https://github.com/Foso/Ktorfit/compare/v1.0.0-beta15...v1.0.0-beta16
⬆️ Deps updates
- based on Ktor 2.1.2
🐛 Bugs fixed
- kotlinx.coroutines.JobCancellationException: Parent job is Completed #70
💥 Breaking changes
- reverted the api of converters to the state of beta13, see #71
- when you are updating from beta13, this is the only change to converters: returnTypeName is replaced through typeData, you can use typeData.qualifiedName to get the same value as returnTypeName
NEW:
- Query parameters can now be nullable, null values will be ignored in requests
- Function return types can now be nullable
FIX:
- Url annotation not resolved correctly #65
BREAKING CHANGES:
-
Changed naming of Converters:
- SuspendResponseConverter:
- is now called RequestConverter
- the wrapSuspendResponse is now called convertRequest.
- returnTypeName is replaced through typeData, you can use typeData.qualifiedName to get the same value as returnTypeName RequestConverter need to be added with the requestConverter() on your Ktorfit object.
- https://foso.github.io/Ktorfit/requestconverter/
- ResponseConverters:
- returnTypeName is replaced through typeData, you can use typeData.qualifiedName to get the same value as returnTypeName https://foso.github.io/Ktorfit/responseconverter/
- SuspendResponseConverter:
- KtorfitCallResponseConverter and KtorfitSuspendCallResponseConverter are now combined in KtorfitCallResponseConverter
- based on Ktor 2.1.1
Fixed:
- Url annotation not resolved correctly #52
wrapResponse from SuspendResponseConverter got renamed to wrapSuspendResponse. This add the possibility to have ResponseConverter and SuspendResponseConverter implemented in the same class.
- throw compiler time error when you use @Path without the corresponding value inside the relative url path
- every generated implementation class of an interface that Ktorfit generates will now contain a "create" ext function that can be used instead of the generic create() function e.g. Let's say you have a interface GithubService, then you can create an instance like this:
val ktorfit = ktorfit {
baseUrl("http://example.com/")
}.create<GithubService>()
or this
val ktorfit = ktorfit {
baseUrl("http://example.com/")
}.createGithubService()
By default, IntelliJ/Android Studio can't find the generated code, you need to add the KSP generated folder to the sourcesets like this: (See more here: https://kotlinlang.org/docs/ksp-quickstart.html#make-ide-aware-of-generated-code)
kotlin.srcDir("build/generated/ksp/jvm/jvmMain/")
- you can now use ResponseConverter in combination with suspend functions. Implement the SuspendResponseConverter
- KtorfitCallResponseConverter and FlowResponseConverter moved to de.jensklingenberg.ktorfit.converter.builtin
- based on Ktor 2.0.2
- added windows target #26
- @PATCH, @POST, @PUT now have a default value #22
- Ktorfit now uses a builder pattern for setup e.g. change this:
Ktorfit("https://example.com/", HttpClient {})
to this:
Ktorfit.Builder()
.baseUrl("https://example.com/")
.httpClient(HttpClient {})
.build()
@Headers now requires a vararg of String instead of an Array e.g. you need to change from:
@Headers(
["Authorization: token ghp_abcdefgh",
"Content-Type: application/json"]
)
to this:
@Headers(
"Authorization: token ghp_abcdefgh",
"Content-Type: application/json"
)
- #15 fix encoding of query parameters
- fix issue with Koin Annotations
- fix issue with FormUrlEncoded
- based on Ktor 2.0.2
- fix issue with KSP 1.0.5 #19
- fixed: Custom Http Method with @Body is now possible #6
- based on Ktor 2.0.1
- cleanup example project @mattrob33
initial release