-
Notifications
You must be signed in to change notification settings - Fork 93
Description
The current behavior implemented in response to #716 is incorrect. Whenever a property is not nullable, it gets marked as required even if it has a default value, which is an error. A property which has a default value is not required.
I realize that the current behavior may be a sane default for the Java world due to the absence of type-level nullability and the absence of default values. You are forced to conflate the two orthogonal attributes.
Since Kotlin does have language-level support for both default values and nullability, SmallRye OpenAPI should be able to take these language features into consideration.
The presence or absence of a default value in a property declaration must only affect the required attribute.
Nullability or non-nullability of a property must only affect the nullable attribute.
val s: String should produce required = true; nullable = false
val s: String = "default" should produce required = false; nullable = false; default = "default"
val s: String? should produce required = true; nullable = true
val s: String? = null should produce required = false; nullable = true; default = null