Skip to content

Commit

Permalink
fix: add geary to default namespaces in PolymorphicListAsMapSerializer
Browse files Browse the repository at this point in the history
  • Loading branch information
0ffz committed Oct 18, 2024
1 parent 093a8f1 commit ef3ecae
Showing 1 changed file with 3 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -99,12 +99,13 @@ open class PolymorphicListAsMapSerializer<T : Any>(
if (key.startsWith("kotlin.")) {
return@runCatching serializersModule.getPolymorphic(polymorphicSerializer.baseClass, key) as KSerializer<T>
}
val defaultNamespaces = namespaces.plus("geary").toSet()
val parsedKey = "${config.prefix}$key".fromCamelCaseToSnakeCase()
return@runCatching (if (parsedKey.hasNamespace())
serializersModule.getPolymorphic(polymorphicSerializer.baseClass, parsedKey)
else namespaces.firstNotNullOfOrNull { namespace ->
else defaultNamespaces.firstNotNullOfOrNull { namespace ->
serializersModule.getPolymorphic(polymorphicSerializer.baseClass, "$namespace:$parsedKey")
} ?: error("No serializer found for $parsedKey in any of the namespaces $namespaces"))
} ?: error("No serializer found for $parsedKey in any of the namespaces $defaultNamespaces"))
as? KSerializer<T> ?: error("Serializer for $parsedKey is not a component serializer")
}

Expand Down

0 comments on commit ef3ecae

Please sign in to comment.