Describe the bug
After upgrading from springdoc-openapi-starter-webmvc-ui 3.0.1 to 3.0.2 (and confirmed still present in 3.0.3), every parameter and schema property that does not have an explicit default value now gets an explicit "default": null written into the generated OpenAPI spec (/v3/api-docs), instead of the default field being omitted as before.
This appears to be a side effect of #3198 ("Property resolution for parameter default values"), which was merged into 3.0.2.
The most visible symptom: for endpoints with a request body, Swagger UI's "Example Value" tab now renders a literal null instead of a populated JSON example object.
To Reproduce
Steps to reproduce the behavior:
- Spring Boot version: 4.1.0
- springdoc-openapi version: 3.0.3 (bug also present in 3.0.2; confirmed not present in 3.0.1)
Minimal reproduction (adjust to your own header parameter / DTO if you can't share the original):
@Operation(
parameters = {
@Parameter(
name = "X-Request-Signature",
in = ParameterIn.HEADER,
required = true,
style = ParameterStyle.SIMPLE,
explode = false,
schema = @Schema(type = "string", format = "hex")
)
}
)
@PostMapping("/example")
public ResponseEntity<Void> example(@RequestBody SomeDto body) {
...
}
Expected behavior
When no default value is set on a parameter/schema, the default field should be omitted from the generated OpenAPI document (as it was in 3.0.1 and earlier), not written out as default: null.
Actual behavior
Generated /v3/api-docs output, comparing 3.0.1 vs 3.0.2/3.0.3 for the same code, no changes on our side:
3.0.1 (correct):
X-Request-Signature:
name: X-Request-Signature
in: header
required: true
style: simple
explode: false
schema:
type: string
format: hex
3.0.2 / 3.0.3 (regression):
X-Request-Signature:
name: X-Request-Signature
in: header
required: true
style: simple
explode: false
schema:
type: string
format: hex
default: null
This default: null is added consistently across the whole generated spec, not just for this one parameter.
Impact
In Swagger UI, for endpoints with a request body, the "Example Value" tab renders null instead of a structured JSON example of the request body schema — presumably because the example-generation logic is affected by the now-present (but meaningless) default: null entries throughout the schema tree. This makes it impossible for API consumers to see a usable example payload in the UI.
Versions
- springdoc-openapi: 3.0.3 (bug present since 3.0.2; not present in 3.0.1)
- Spring Boot: 4.1.0
- Confirmed cause narrowed down via bisection: downgrading only
springdoc-openapi-starter-webmvc-ui from 3.0.3 → 3.0.1 (no other changes) resolves both the default: null entries (including for the header parameter shown above) and the Swagger UI "Example Value: null" issue.
Additional context
Suspected root cause: #3198 changed how default values for parameters are resolved (to support property placeholder resolution, e.g. ${some.property}), and appears to have introduced a regression where an unset default is now serialized as an explicit null instead of being omitted.
Happy to provide more of our OpenAPI config or a minimal standalone reproduction project if useful.
Describe the bug
After upgrading from
springdoc-openapi-starter-webmvc-ui3.0.1 to 3.0.2 (and confirmed still present in 3.0.3), every parameter and schema property that does not have an explicit default value now gets an explicit"default": nullwritten into the generated OpenAPI spec (/v3/api-docs), instead of thedefaultfield being omitted as before.This appears to be a side effect of #3198 ("Property resolution for parameter default values"), which was merged into 3.0.2.
The most visible symptom: for endpoints with a request body, Swagger UI's "Example Value" tab now renders a literal
nullinstead of a populated JSON example object.To Reproduce
Steps to reproduce the behavior:
Minimal reproduction (adjust to your own header parameter / DTO if you can't share the original):
Expected behavior
When no default value is set on a parameter/schema, the
defaultfield should be omitted from the generated OpenAPI document (as it was in 3.0.1 and earlier), not written out asdefault: null.Actual behavior
Generated
/v3/api-docsoutput, comparing 3.0.1 vs 3.0.2/3.0.3 for the same code, no changes on our side:3.0.1 (correct):
3.0.2 / 3.0.3 (regression):
This
default: nullis added consistently across the whole generated spec, not just for this one parameter.Impact
In Swagger UI, for endpoints with a request body, the "Example Value" tab renders
nullinstead of a structured JSON example of the request body schema — presumably because the example-generation logic is affected by the now-present (but meaningless)default: nullentries throughout the schema tree. This makes it impossible for API consumers to see a usable example payload in the UI.Versions
springdoc-openapi-starter-webmvc-uifrom 3.0.3 → 3.0.1 (no other changes) resolves both thedefault: nullentries (including for the header parameter shown above) and the Swagger UI "Example Value: null" issue.Additional context
Suspected root cause: #3198 changed how default values for parameters are resolved (to support property placeholder resolution, e.g.
${some.property}), and appears to have introduced a regression where an unset default is now serialized as an explicitnullinstead of being omitted.Happy to provide more of our OpenAPI config or a minimal standalone reproduction project if useful.