-
Notifications
You must be signed in to change notification settings - Fork 40
Description
Hi! I'm currently trying to implement RPC for database access for an admin panel of my pet-project. Server-side database API utilizes Java's LocalDate
and LocalDateTime
classes, which do not have default serializers in kotlinx.serialization, but I've written custom serializers for them by hand.
I've tried to annotate all LocalDate
fields with @Serializable()
annotation specifying serializer to use, but that didn't help and build still failed with messages like: DatabaseAbsenceRPCClient.kt:58:58 Serializer has not been found for type 'LocalDate'. To use context serializer as fallback, explicitly annotate type or property with @Contextual
. Not including these annotations doesn't affect build's failure to build too. :)
Declaration file:
interface DatabaseAbsenceRPC : RPC {
// ...
suspend fun getAbsences(date: @Serializable(with = LocalDateSerializer::class) LocalDate): List<AbsenceRecord>
}
So, my question is: would it be possible to somehow read these annotations in code-generation time and apply them to the generated code too? I think, I'm not the only one who uses custom serializers in kotlinx.serialization, so that would be a nice-to-have feature so we don't have to write boilerplate code to transform from-LocalDate-to-String and back :)
Awesome work on the library, btw! Looks promising!