Description
Describe the bug
- Setting the required field to false in the @Schema annotation on a field in Kotlin gets ignored when the field is non-nullable
To Reproduce
Steps to reproduce the behavior:
-
What version of spring-boot you are using? 2.5.12
-
What modules and versions of springdoc-openapi are you using?
implementation("org.springdoc:springdoc-openapi-webmvc-core:1.6.14")
implementation("org.springdoc:springdoc-openapi-kotlin:1.6.14")
implementation("org.springdoc:springdoc-openapi-security:1.6.14")
-
What is the actual and the expected result using OpenAPI Description (yml or json)?
The expected behavior is that the field will not be listed as required, but it is getting listed as required. -
Provide with a sample code (HelloController) or Test that reproduces the problem
@field:Schema(required = false, description = "Should not be required") val nonNullableWithDefault: String = "a default value",
Expected behavior
I would expect the field to not be marked as required. We should be able to have full control over the spec.
Additional context
This was brought up in both #1468 and #1285 but dismissed. Based on some comments of others in the threads and my own opinion, this does appear to be a bug from our perspective. I wanted to bring this up one more time. If it is decided that it will not get addressed, maybe we can at least get some documentation added around the behavior with Kotlin?