OpenAPITools / OpenAPITools/openapi-generator
[REQ] Kotlin generators should support generation of value class if applicable
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.
It would make code safer and easier to read if a Kotlin generator would support the generation of value classes if applicable.
See https://kotlinlang.org/docs/inline-classes.html for Kotlin value class details
Describe the solution you'd like
This might be an optional setting which probably needs to be defined in the generator config. I could not find anything in openapi itself that would suggest that value classes are supported.
If an openapi defined object has one single attribute of a primitive type (+String), a value class can and should be generated. The name should be derivable from the openapi definition.
Street:
type: object
required:
- name
properties:
name:
type: string
description: "The name of the street as part of an address"
could be generated as
@JvmInline value class Street(val name: String)
What do you think?
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
Start by reviewing the Kotlin generator and its generator configuration to determine how an optional value-class setting could be represented. Use the provided single-primitive-property OpenAPI example as the acceptance case; done means the generator can produce the proposed Street value class when the setting and applicability conditions are met.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- kotlin
- Domain
- api, tooling
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100