Support for non-nullable types in Kotlin
See original GitHub issueNB: 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:
- Created 4 years ago
- Reactions:7
- Comments:9 (2 by maintainers)
Top 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 >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
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.
It seems that it does not work for request body parameters and responses wrapped with ResponseEntity