-
Notifications
You must be signed in to change notification settings - Fork 6
feat: Add SerializersModule support to KxsTsGenerator #209
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
base: main
Are you sure you want to change the base?
Conversation
This change modifies the `KxsTsGenerator` to accept a `SerializersModule` in its constructor. This module is then used to resolve contextual and polymorphic serializers during the TypeScript generation process. The `SerializerDescriptorsExtractor` has been refactored to use the `SerializersModule.dumpTo` experimental API to collect all serializers from the module. This allows for a platform-independent way to handle complex serialization scenarios.
Thanks for the PR! It's been a while since I've worked on this project so I'll have to dust off some cobwebs (both in my recollections and the project). |
|
||
companion object { | ||
|
||
fun default(serializersModule: SerializersModule) = |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
serializersModule
is unused here. How should it be used?
test("Example4: expect contextual serializer to be extracted") { | ||
val module = SerializersModule { | ||
contextual(Example4.SomeType::class, Example4.SomeType.serializer()) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This test still passes if the custom contextual(...)
is commented out.
test("Example5: expect polymorphic serializer to be extracted") { | ||
val module = SerializersModule { | ||
polymorphic(Example5.Parent::class, Example5.SubClass::class, Example5.SubClass.serializer()) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This test still passes if the custom polymorphic(...)
is commented out.
open val sourceCodeGenerator: TsSourceCodeGenerator = TsSourceCodeGenerator.Default(config), | ||
open val serializersModule: SerializersModule = SerializersModule { }, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of SerializersModule { }
please use EmptySerializersModule()
This change modifies the
KxsTsGenerator
to accept aSerializersModule
in its constructor. This module is then used to resolve contextual and polymorphic serializers during the TypeScript generation process.The
SerializerDescriptorsExtractor
has been refactored to use theSerializersModule.dumpTo
experimental API to collect all serializers from the module. This allows for a platform-independent way to handle complex serialization scenarios.Closes #6