question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Support for non-nullable types in Kotlin

See original GitHub issue

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.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:7
  • Comments:9 (2 by maintainers)

github_iconTop GitHub Comments

6reactions
fveerdencommented, Feb 20, 2020

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.

3reactions
lsuskicommented, Mar 3, 2020

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

Read more comments on GitHub >

github_iconTop Results From Across the Web

Null safety - Kotlin
Nullable types and non-null types ... Kotlin's type system is aimed at eliminating the danger of null references, also known as The Billion...
Read more >
Kotlin Nullable Non Nullable Safety - Javatpoint
Kotlin null safety is a procedure to eliminate the risk of null reference from the code. Kotlin compiler throws NullPointerException immediately if it...
Read more >
A complete guide to null safety in Kotlin - LogRocket Blog
The reason is that Java does not support null safety, and non-nullable types do not exist. In other terms, any variable is always...
Read more >
Use nullability in Kotlin - Android Developers
This codelab teaches you about nullability and the importance of null safety. Nullability is a concept commonly found in many programming ...
Read more >
Kotlin Null Safety - GeeksforGeeks
Nullable and Non-Nullable Types in Kotlin – ... Kotlin type system has distinguish two types of references that can hold null (nullable references) ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found