Skip to content

Commit a49d634

Browse files
committed
[JAVA-SPRING] Fix missing nullable on all args constructor and fluent setters
1 parent baaf9f9 commit a49d634

3 files changed

Lines changed: 7 additions & 6 deletions

File tree

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{{#lambda.jSpecifyDatatype}}{{{datatypeWithEnum}}}{{/lambda.jSpecifyDatatype}}

‎modules/openapi-generator/src/main/resources/JavaSpring/pojo.mustache‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ public {{>sealed}}class {{classname}}{{#parent}} extends {{{parent}}}{{/parent}}
134134
/**
135135
* Constructor with all args parameters
136136
*/
137-
public {{classname}}({{#vendorExtensions.x-java-all-args-constructor-vars}}{{>nullableAnnotation}}{{{datatypeWithEnum}}} {{name}}{{^-last}}, {{/-last}}{{/vendorExtensions.x-java-all-args-constructor-vars}}) {
137+
public {{classname}}({{#vendorExtensions.x-java-all-args-constructor-vars}}{{>nullableAnnotation}}{{>nullableDatatypeWithEnum}} {{name}}{{^-last}}, {{/-last}}{{/vendorExtensions.x-java-all-args-constructor-vars}}) {
138138
{{#parent}}
139139
super({{#parentVars}}{{name}}{{^-last}}, {{/-last}}{{/parentVars}});
140140
{{/parent}}
@@ -153,7 +153,7 @@ public {{>sealed}}class {{classname}}{{#parent}} extends {{{parent}}}{{/parent}}
153153
{{^lombok.Data}}
154154

155155
{{! begin feature: fluent setter methods }}
156-
public {{classname}} {{name}}({{>nullableAnnotation}}{{{datatypeWithEnum}}} {{name}}) {
156+
public {{classname}} {{name}}({{>nullableAnnotation}}{{>nullableDatatypeWithEnum}} {{name}}) {
157157
{{#openApiNullable}}
158158
this.{{name}} = {{#isNullable}}JsonNullable.of({{/isNullable}}{{#useOptional}}{{^required}}{{^isNullable}}{{^isContainer}}Optional.of{{#optionalAcceptNullable}}Nullable{{/optionalAcceptNullable}}({{/isContainer}}{{/isNullable}}{{/required}}{{/useOptional}}{{name}}{{#isNullable}}){{/isNullable}}{{#useOptional}}{{^required}}{{^isNullable}}{{^isContainer}}){{/isContainer}}{{/isNullable}}{{/required}}{{/useOptional}};
159159
{{/openApiNullable}}

‎samples/openapi3/server/petstore/springboot-4-jspecify/src/main/java/org/openapitools/model/Foo.java‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ public Foo(OffsetDateTime requiredDt) {
7070
/**
7171
* Constructor with all args parameters
7272
*/
73-
public Foo(OffsetDateTime dt, org.springframework.core.io.Resource binary, List<OffsetDateTime> listOfDt, List<OffsetDateTime> listMinIntems, OffsetDateTime requiredDt, BigDecimal number) {
73+
public Foo(@Nullable OffsetDateTime dt, org.springframework.core.io.@Nullable Resource binary, List<OffsetDateTime> listOfDt, List<OffsetDateTime> listMinIntems, OffsetDateTime requiredDt, @Nullable BigDecimal number) {
7474
this.dt = dt;
7575
this.binary = binary;
7676
this.listOfDt = listOfDt;
@@ -79,7 +79,7 @@ public Foo(OffsetDateTime dt, org.springframework.core.io.Resource binary, List<
7979
this.number = number;
8080
}
8181

82-
public Foo dt(OffsetDateTime dt) {
82+
public Foo dt(@Nullable OffsetDateTime dt) {
8383
this.dt = dt;
8484
return this;
8585
}
@@ -104,7 +104,7 @@ public void setDt(@Nullable OffsetDateTime dt) {
104104
this.dt = dt;
105105
}
106106

107-
public Foo binary(org.springframework.core.io.Resource binary) {
107+
public Foo binary(org.springframework.core.io.@Nullable Resource binary) {
108108
this.binary = binary;
109109
return this;
110110
}
@@ -223,7 +223,7 @@ public void setRequiredDt(OffsetDateTime requiredDt) {
223223
this.requiredDt = requiredDt;
224224
}
225225

226-
public Foo number(BigDecimal number) {
226+
public Foo number(@Nullable BigDecimal number) {
227227
this.number = number;
228228
return this;
229229
}

0 commit comments

Comments
 (0)