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

Expose SerialModule in KMongoSerializationRepository #176

Closed
bizarre opened this issue Feb 19, 2020 · 3 comments
Closed

Expose SerialModule in KMongoSerializationRepository #176

bizarre opened this issue Feb 19, 2020 · 3 comments

Comments

@bizarre
Copy link
Contributor

bizarre commented Feb 19, 2020

We're using kmongo alongside ktor and using Kotlinx Serialization on both sides. We'd like to be able to use the same models that we use for kmongo with ktor, but none of the bindings are exposed publicly. We're currently using a less than ideal reflection solution to fetch the module getter in KMongoSerializationRepository and then passing that directly into the constructor of kotlinx.serialization.json.Json.

@zigzago
Copy link
Member

zigzago commented Feb 19, 2020

@bizarre a PR would be appreciated. KMongo allows to add modules using org.litote.kmongo.serialization.registerModule function. Not sure to understand well why you need to access to KMongoSerializationRepository.module ;)

@bizarre
Copy link
Contributor Author

bizarre commented Feb 19, 2020

@zigzago For example, let's say we have a Id<Model> field in an object. Kmongo has no problem serializing it because the serializer (IdSerializer, I believe) is available in its SerialModule. However, if we want to serialize the same object in an external serial format, kotlinx.serialization won't be able to find the serializer since its not in context. If KMongoSerializationRepository.module is exposed then we'd be able to add all the kmongo-specific serializers into context.

@zigzago
Copy link
Member

zigzago commented Feb 28, 2020

Merged

@zigzago zigzago closed this as completed Feb 28, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants