openapi-generator
openapi-generator copied to clipboard
Kotlin - kotlinx.serialization - polymorphism
Currently Kotlin multiplatform didn't support Polymorphic Serializer.
I have implemented the polymorphic support by using JsonContentPolymorphicSerializer from kotlinx.serialization
You can check the sample : samples/client/petstore/kotlin-multiplatform-polymorphic
internal object AnimalSerializer : JsonContentPolymorphicSerializer<Animal>(Animal::class) {
override fun selectDeserializer(element: JsonElement) = when {
"BIRD" in element.jsonObject["type"].toString() -> Bird.serializer()
else -> Animal.serializer()
}
}
One thing I'm not confident is the modification in data_class.mustache
concerning the use of the parent constructor
PR checklist
- [X] Read the contribution guidelines.
- [X] Pull Request title clearly describes the work in the pull request and Pull Request description provides details about how to validate the work. Missing information here may result in delayed response from the community.
- [X] Run the following to build the project and update samples:
Commit all changed files. This is important, as CI jobs will verify all generator outputs of your HEAD commit as it would merge with master. These must match the expectations made by your contribution. You may regenerate an individual generator by passing the relevant config(s) as an argument to the script, for example./mvnw clean package ./bin/generate-samples.sh ./bin/utils/export_docs_generators.sh
./bin/generate-samples.sh bin/configs/java*
. For Windows users, please run the script in Git BASH. - [X] File the PR against the correct branch:
master
(6.3.0) (minor release - breaking changes with fallbacks),7.0.x
(breaking changes without fallbacks) - [X] If your PR is targeting a particular programming language, @mention the technical committee members, so they are more likely to review the pull request.
- Technical committee : @jimschubert, @dr4ke616 @karismann @Zomzog @andrewemery @4brunu @yutaka0m
#14548
Would really love to see this change get in.
@loicsiret thanks for the PR. Can you please PM me via Slack to discuss this further?
https://join.slack.com/t/openapi-generator/shared_invite/zt-12jxxd7p2-XUeQM~4pzsU9x~eGLQqX2g
Did this conversation happen?
Yes, just need some time for improving tests
Le lun. 14 août 2023, 16:53, Tyler Thrailkill @.***> a écrit :
Did this conversation happen?
— Reply to this email directly, view it on GitHub https://github.com/OpenAPITools/openapi-generator/pull/14301#issuecomment-1678043404, or unsubscribe https://github.com/notifications/unsubscribe-auth/AA7JLFUD4F4SZNYRDMKGB7DXVKF27ANCNFSM6AAAAAATE4QSNU . You are receiving this because you were mentioned.Message ID: @.***>
@snowe2010 if you've time to contribute a test or 2, please reply to let us know.
I am not snowe2010, however I'd be interested in helping with some tests.
The fact is that there are a lot of change in the code that impact this PR, I'm working on it !
Le jeu. 26 oct. 2023 à 09:33, Manuel Dossinger @.***> a écrit :
I am not snowe2010, however I'd be interested in helping with some tests.
— Reply to this email directly, view it on GitHub https://github.com/OpenAPITools/openapi-generator/pull/14301#issuecomment-1781136181, or unsubscribe https://github.com/notifications/unsubscribe-auth/AA7JLFUQT3OKFHZMBXGOFZLYBJRBFAVCNFSM6AAAAAATE4QSNWVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTOOBRGEZTMMJYGE . You are receiving this because you were mentioned.Message ID: @.***>