swagger-core
swagger-core copied to clipboard
kotlin field annotated by @Schema(required = false, defaultValue = "") recognized as required
class Foo
@Schema(required = false, defaultValue = "")
var bar: String = ""
}
I was facing the same problem (with an optional boolean in a @ReponseBody data class), and the only way to make it not required in the schema was to make it nullable (which it should not be):
data class Body(
@get:Schema(required = false) //this doesn't work
val verified: Boolean? = false //as Boolean it's required even with a default value, as Boolean? it's not required
)
I was facing the same issue with attempting to update the Swagger docs to be required = false since I would think that it should be possible to override the Swagger docs on specific values you know are not required 🤔
Thank you @darioseidl for a simple fix! 👏