-
-
Notifications
You must be signed in to change notification settings - Fork 7k
Kotlinx polymorphism with custom discriminator support #21531
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: master
Are you sure you want to change the base?
Conversation
- added new config with kotlinx, discriminator (/w custom name) and kotlinx_serialization - remove discriminator properties from the generator in both base and derived classes - set discriminatorValue in additionalProperties of derived classes - add JsonClassDiscriminator the derived classes in the template - set SerialName to discriminatorValue in the template - change base classes to sealed class instead of interface - make variables in base classes abstract
@@ -0,0 +1,10 @@ | |||
generatorName: kotlin | |||
outputDir: samples/client/petstore/kotlin-allOff-discriminator-kotlinx-serialization |
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.
thanks for the PR. what about adding the new folder to the github workflow so that it will be tested moving forward?
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.
done in 1f8973a
objs = super.postProcessAllModels(objs); | ||
if (getSerializationLibrary() == SERIALIZATION_LIBRARY_TYPE.kotlinx_serialization) { | ||
for (Map.Entry<String, ModelsMap> modelsMap : objs.entrySet()) { | ||
for (ModelMap mo : modelsMap.getValue().getModels()) { |
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.
minor suggestion: add some comments in this for loop to explain what it tries to archive
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.
done in 06d993c
PR checklist
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
./bin/generate-samples.sh bin/configs/java*
.IMPORTANT: Do NOT purge/delete any folders/files (e.g. tests) when regenerating the samples as manually written tests may be removed.
master
(upcoming7.x.0
minor release - breaking changes with fallbacks),8.0.x
(breaking changes without fallbacks)@dr4ke616 @karismann @Zomzog @andrewemery @4brunu @yutaka0m @stefankoppier @e5l