GeezerVison is showing github.com — Empty default values are ignored · Issue #4838 · swagger-api/swagger-core
Empty default values are ignored #4838DescriptionEmpty default values (@Schema(defaultValue = "")) are not included into generated OpenAPI yaml file.
Related code:
|
if (StringUtils.isNotBlank(schema.defaultValue())) { |
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. Activityjuntae6942 commented on Sep 8, 2025 westito I'd like to work on a fix for this. Could you please assign it to me? westito commented on Sep 17, 2025 Reacted by Bello🥔 Reacted by Bello🥔 daniel-kmiecik commented on Feb 26, 2026 Thank you for raising this issue.
Here's a prepared PR to fix it: #5063
@juntae6942 many thanks for your engagement, but we need to avoid breaking change and your PR is not complete. daniel-kmiecik commented on Feb 26, 2026 The fix will be available with the next release. Thank you all! rbioteau commented on Mar 4, 2026 Hi, just for the record, this change introduced a breaking change, if, like me, you are stuck on Springframework 5.x or Springboot 2.x.
The latest version I can use of springdoc-openapi is 1.8.0 and it doesn't understand the new sentinel introduced in #5063.
HTH MohTaheri commented on Mar 4, 2026 Yes, that’s also breaking on our side after updating to the latest version of springdoc 3.0.2
"400": description: "Bad Request" content: application/json: schema: $ref: "#/components/schemas/Error" additionalProperties: default: "##default" contains: default: "##default" default: "##default" items: default: "##default" unevaluatedItems: default: "##default" Reacted by Christopher Cudennec and Timon Back zdary commented on Mar 10, 2026 @juntae6942 @westito this change broke default values rendering for enums badly.
value ##default is rendered anywhere where default value was not defined at all.
this used to be a drop box with possible enum values. daniel-kmiecik commented on Mar 10, 2026 Fix has been released. Please verify again. ahoehma commented on Mar 20, 2026 I found that with the update of io.swagger.core.v3:swagger-annotations-jakarta 2.2.43 → 2.2.45 I have "##defaults" all over the place.
I'm using org.springdoc:springdoc-openapi 3.0.1.
Example:

Any idea what I can do to avoid this? Reacted by Henrik Eriksson HenrikErikssonSU commented on Mar 24, 2026 Thanks! I just run into the same issue.
MetadataMetadataDevelopmentNo branches or pull requestsIssue actions
|