Created by: kvn-stgl
Currently it's not possible to use Kotlin and Moshi with the oneOf-Keyword. I tried to implement the PolymorphicJsonAdapterFactory
to support this feature.
The reason why I set the target branch to master
is because the current strategy will fail during runtime (it's not allowed with moshi to serialize a interface directly).
I tested it with the following config:
generatorName: kotlin
outputDir: samples/client/3_0/kotlin-retrofit2-moshi-polymorphic
library: jvm-retrofit2
inputSpec: modules/openapi-generator/src/test/resources/3_0/allOf.yaml
templateDir: modules/openapi-generator/src/main/resources/kotlin-client
additionalProperties:
serializationLibrary: moshi
artifactId: kotlin-retrofit2-moshi-polymorphic
moshiCodeGen: "true"
Saddly in the current petstore samples are no discriminator, that's why I didn't add a sample. My plans for the future are to directly change the interface to a sealed class
. Any recommendations for the strategy therefore?
PR checklist
-
Read the contribution guidelines. -
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. -
Run the following to build the project and update samples: ./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. -
File the PR against the correct branch: master
,5.1.x
,6.0.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