Is your feature request related to a problem? Please describe.
the generated openapi doesn't include nullable and required fields properly when annotated for OpenAPI31.
nullable: Controls whether a field's value can be null (i.e., the JSON value can be null) DataRestDelegatingMethodParameterCustomizer.java:323-325
requiredMode = NOT_REQUIRED: Controls whether the field must be present in the request/response (i.e., whether the field key must exist in the JSON) SchemaUtils.java:134-136
- A clear and concise description of what the problem is. Ex. I'm always frustrated
example DTO
@Nullable
@Schema(
nullable = true,
requiredMode = RequiredMode.NOT_REQUIRED
)
private String field;
The library does not currently set nullable = true or use type arrays like type: ["string", "null"] for nullable fields in OpenAPI 3.1, even when you explicitly use @Schema(nullable = true) or @Nullable.
The OpenAPI 3.1 specification supports type arrays for nullable fields (e.g., type: ["string", "null"]), but springdoc-openapi doesn't currently generate them automatically. The library only explicitly sets nullable = false for non-nullable fields when validation annotations are present, and doesn't add any nullable indicators for fields that can be null.
requiredMode doesn't do anything either.
Describe the solution you'd like
generate the nullable section
OpenAPI 3.0 approach:
{
"type": "string",
"nullable": true
}
OpenAPI 3.1.0 approach:
{
"type": ["string", "null"]
}
Is your feature request related to a problem? Please describe.
the generated openapi doesn't include nullable and required fields properly when annotated for OpenAPI31.
nullable: Controls whether a field's value can be null (i.e., the JSON value can be null) DataRestDelegatingMethodParameterCustomizer.java:323-325requiredMode= NOT_REQUIRED: Controls whether the field must be present in the request/response (i.e., whether the field key must exist in the JSON) SchemaUtils.java:134-136example DTO
The library does not currently set
nullable = trueor use type arrays like type:["string", "null"]for nullable fields in OpenAPI 3.1, even when you explicitly use@Schema(nullable = true)or@Nullable.The OpenAPI 3.1 specification supports type arrays for nullable fields (e.g., type: ["string", "null"]), but springdoc-openapi doesn't currently generate them automatically. The library only explicitly sets nullable = false for non-nullable fields when validation annotations are present, and doesn't add any nullable indicators for fields that can be null.
requiredModedoesn't do anything either.Describe the solution you'd like
generate the nullable section
OpenAPI 3.0 approach:
OpenAPI 3.1.0 approach: