OpenAPITools / OpenAPITools/openapi-generator
[REQ] Support for kotlinx.serialization in the Kotlin generator for Kotlin Multiplatform Mobile (KMM) projects
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 26.8k
- Forks
- 7.7k
- PR merge metrics
- PR metrics pending
Description
Is your feature request related to a problem? Please describe.
Yes, currently the OpenAPI Generator does not offer support for kotlinx.serialization library for JSON serialization in its Kotlin generator. For developers working on Kotlin Multiplatform Mobile (KMM) projects, kotlinx.serialization is the recommended library as it provides cross-platform compatibility. However, the current setup in the generator uses libraries not designed for Kotlin/Native, which creates a hurdle for KMM projects.
Describe the solution you'd like
It would be ideal if the OpenAPI Generator could provide an option to generate kotlinx.serialization-compatible code. This could involve an extension of the jsonLibrary option to include "kotlinx" or a similar marker. Model classes would then be annotated with @Serializable, and API clients would utilize kotlinx.serialization JSON parsers to serialize and deserialize payloads.
Describe alternatives you've considered
An alternative could involve manually adapting the code generated by the generator, adding @Serializable annotations and adjusting serialization logic. However, this could become tedious with API changes and is not optimal.
Additional context
With the rising popularity of KMM projects, supporting kotlinx.serialization could help make the OpenAPI Generator more accessible to a broader group of developers. It would be a beneficial extension ensuring the OpenAPI Generator’s timeliness and relevance in the ever-evolving world of Kotlin development.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
The request concerns the Kotlin generator's jsonLibrary option, generated model annotations, and API-client JSON serialization. Start by tracing those generator entry points and compare the current libraries with KMM requirements; done means an option for kotlinx.serialization generates compatible models and client serialization. No file or test paths are named in the issue.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- kotlin
- Domain
- mobile-dev, tooling
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 30/100