George
01/19/2022, 9:18 AMGeorge
01/20/2022, 9:35 AMGeorge
01/20/2022, 9:38 AMorg.apiplayground.apitest.payload.SharedPayload
(no Creators, like default constructor, exist): abstract types either need to be mapped to concrete types, have custom deserializer, or contain additional type informationEmil Kantis
01/20/2022, 11:43 AMWebFluxConfigurer
bean and ExchangeStrategies
.. We have something like this in place.
@Configuration
class SerializationConfig {
@Bean
fun json(): Json = Json {
// Your config for KotlinX serialization
}
@Bean
fun kotlinSerializationJsonEncoder(json: Json) = KotlinSerializationJsonEncoder(json)
@Bean
fun kotlinSerializationJsonDecoder(json: Json) = KotlinSerializationJsonDecoder(json)
@Bean
fun exchangeStrategies(
encoder: KotlinSerializationJsonEncoder,
decoder: KotlinSerializationJsonDecoder
): ExchangeStrategies =
ExchangeStrategies.builder()
.codecs { configurer ->
configurer.defaultCodecs()
.apply {
kotlinSerializationJsonDecoder(decoder)
kotlinSerializationJsonEncoder(encoder)
}
}
.build()
@Bean
fun webFluxConfigurer(
encoder: KotlinSerializationJsonEncoder,
decoder: KotlinSerializationJsonDecoder
): WebFluxConfigurer =
object : WebFluxConfigurer {
override fun configureHttpMessageCodecs(configurer: ServerCodecConfigurer) {
configurer.defaultCodecs().kotlinSerializationJsonEncoder(encoder)
configurer.defaultCodecs().kotlinSerializationJsonDecoder(decoder)
}
}
}
Emil Kantis
01/20/2022, 11:49 AMExchangeStrategies
will be used by WebClient
for outbound requests and WebFluxConfigurer
setups up your controllers to use KotlinX.serialization for inbound requests (IIRC)George
01/20/2022, 2:00 PMEmil Kantis
01/20/2022, 2:03 PMGeorge
01/20/2022, 2:09 PMGeorge
01/20/2022, 2:10 PMEmil Kantis
01/20/2022, 2:22 PMGeorge
01/20/2022, 2:24 PMsdeleuze
01/20/2022, 8:19 PMGeorge
01/21/2022, 9:04 AMGeorge
01/24/2022, 12:54 PMGeorge
01/24/2022, 2:05 PMOpen polymorphic serialization is not supported yet
But, i think im not using at all open polymorphic serialization. Just simple @Serializable with some Transient fields. This can be checked out on my example project on github.Emil Kantis
01/24/2022, 2:15 PMGeorge
01/24/2022, 2:15 PMEmil Kantis
01/24/2022, 2:15 PMEmil Kantis
01/24/2022, 2:16 PMGeorge
01/24/2022, 2:21 PMGeorge
01/24/2022, 2:24 PMInterfaces are used in the Kotlin language to enable polymorphism, so all interfaces are considered to be implicitly serializable with the PolymorphicSerializer strategy.
George
01/24/2022, 2:24 PMGeorge
01/24/2022, 2:28 PMEmil Kantis
01/24/2022, 2:30 PM