swagger-core icon indicating copy to clipboard operation
swagger-core copied to clipboard

Empty default values are ignored

Open westito opened this issue 10 months ago • 2 comments

Empty default values (@Schema(defaultValue = "")) are not included into generated OpenAPI yaml file.

Related code: https://github.com/swagger-api/swagger-core/blob/55ef54df305c2fee98ca58cc91c85183478a9b3a/modules/swagger-core/src/main/java/io/swagger/v3/core/util/AnnotationsUtils.java#L751

Empty values are simply ignored, but many code generation tools are rely on this value. For ex. in Dart generator when no default value provieded, the field became required at code level.

The defaultValue in @Schema annotation should be nullable and passing empty value means include in generated schema.

westito avatar Jan 29 '25 22:01 westito

westito I'd like to work on a fix for this. Could you please assign it to me?

juntae6942 avatar Sep 08 '25 02:09 juntae6942

Feel free to fix

westito avatar Sep 17 '25 17:09 westito