Bug Report Checklist
Description
When jspecify is in use, when a field is defined as not required in openApi, it should always be mapped to a @Nullable type pojo.
Even if there is a defaultValue in the openApi spec, the caller can always force the value to null. The defaultValue applies to properties that are not passed, not to properties that are passed explicitly as null.
openapi-generator version
7.22.0. not a regression.
OpenAPI declaration file content or url
components:
schemas:
CobJobDto:
type: object
required: [ date ]
properties:
date:
description: The Business Day to consider for the COB job.
type: string
format: date
example: "2021-01-30"
force:
description: Force a new job to start whatever is the state of the previous.
type: boolean
default: false
example: true
synchronous:
description: Wait for the end of the batch.
type: boolean
default: false
example: true
Generation Details
generated through Maven. The DTO looks like this
@Generated(value = "org.openapitools.codegen.languages.SpringCodegen", date = "2026-07-14T08:25:00.429547+02:00[Europe/Paris]", comments = "Generator version: 7.22.0")
public class CobJobDto {
@DateTimeFormat(iso = DateTimeFormat.ISO.DATE)
private LocalDate date;
private Boolean force = false;
private Boolean synchronous = false;
I expect it to look like this
@Generated(value = "org.openapitools.codegen.languages.SpringCodegen", date = "2026-07-14T08:25:00.429547+02:00[Europe/Paris]", comments = "Generator version: 7.22.0")
public class CobJobDto {
@DateTimeFormat(iso = DateTimeFormat.ISO.DATE)
private LocalDate date;
private @org.jspecify.annotations.Nullable Boolean force = false;
private @org.jspecify.annotations.Nullable Boolean synchronous = false;
Steps to reproduce
Related issues/PRs
Suggest a fix
In the nullableAnnotation.mustache, I think the fact that we put the @Nullable annotation or not should not depend on the defaultValue flag
Bug Report Checklist
Description
When jspecify is in use, when a field is defined as not required in openApi, it should always be mapped to a
@Nullabletype pojo.Even if there is a
defaultValuein the openApi spec, the caller can always force the value tonull. ThedefaultValueapplies to properties that are not passed, not to properties that are passed explicitly asnull.openapi-generator version
7.22.0. not a regression.
OpenAPI declaration file content or url
Generation Details
generated through Maven. The DTO looks like this
I expect it to look like this
Steps to reproduce
Related issues/PRs
Suggest a fix
In the
nullableAnnotation.mustache, I think the fact that we put the@Nullableannotation or not should not depend on thedefaultValueflag