Skip to content

Support for non-nullable types in Kotlin #443

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

Closed
frank-van-eerden opened this issue Feb 18, 2020 · 9 comments
Closed

Support for non-nullable types in Kotlin #443

frank-van-eerden opened this issue Feb 18, 2020 · 9 comments
Labels
enhancement New feature or request

Comments

@frank-van-eerden
Copy link

NB: This is a more specific continuation of issue #269

When generating apidocs from Kotlin data classes the non-nullable fields are not listed as required.

data class Person(
    val name: String
    val nickname: String?
)

The name property should be in the required list:

"Person": {
        "required": [
          "name"
        ],
...

There are workarounds like annotating the non-nullable properties with javax.validation.NotNull, but that is too verbose to my taste.

@bnasslahsen
Copy link
Collaborator

Hi @frank-van-eerden,

The support for non-nullable types in Kotlin will be available on v1.2.32.

@fveerden
Copy link

Hi @bnasslahsen ,

It seems to work for function parameters, but not on the response data classes in the components.schemas section of the openapi document.
Can you reopen the issue?

Kind regards, Frank.

@chrisatrotter
Copy link

I noticed that if a class is wrapped within an EntityModel, then it is not able to show non-nullable fields as required. This might be related to #453 .

@lsuski
Copy link

lsuski commented Mar 3, 2020

It seems that it does not work for request body parameters and responses wrapped with ResponseEntity

@lsuski
Copy link

lsuski commented Mar 5, 2020

It also does not work for fields with complex types (e.g. another data class)

@maapteh
Copy link

maapteh commented Aug 21, 2020

@bnasslahsen is it possible to re-open this issue?

@bnasslahsen
Copy link
Collaborator

@maapteh,

It's all time possible to reopen an issue.
Do you have any additional PR or enhancements to propose?

@maapteh
Copy link

maapteh commented Aug 21, 2020

Unfortunately i have zero PR's in the making. Im just yelling at my backend people :)

"It seems to work for function parameters, but not on the response data classes in the components.schemas section of the openapi document."

@bnasslahsen bnasslahsen added the enhancement New feature or request label Jan 10, 2022
@cwboden
Copy link

cwboden commented Sep 23, 2022

For anyone still curious, I was able to solve this by adding springboot-openapi-kotlin to my pom.xml.

@springdoc springdoc locked as resolved and limited conversation to collaborators Sep 23, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

7 participants