Skip to content
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

[REQ] Kotlin generators should support generation of value class if applicable #19987

Open
orolhawion opened this issue Oct 28, 2024 · 0 comments

Comments

@orolhawion
Copy link
Contributor

orolhawion commented Oct 28, 2024

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant