Skip to content

Commit 48804b0

Browse files
committed
update to handle nullable as well
1 parent b89b267 commit 48804b0

File tree

177 files changed

+919
-919
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

177 files changed

+919
-919
lines changed

modules/openapi-generator/src/main/resources/Java/jackson_annotations.mustache

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
* If the field is required, always include it, even if it is null.
55
* Else use custom behaviour, IOW use whatever is defined on the object mapper
66
}}
7-
@JsonProperty(value = JSON_PROPERTY_{{nameInSnakeCase}}, required = {{required}})
7+
@JsonProperty(value = JSON_PROPERTY_{{nameInSnakeCase}}, required = {{#isNullable}}false{{/isNullable}}{{^isNullable}}{{required}}{{/isNullable}})
88
@JsonInclude({{#isMap}}{{#items.isNullable}}content = JsonInclude.Include.ALWAYS, {{/items.isNullable}}{{/isMap}}value = JsonInclude.Include.{{#required}}ALWAYS{{/required}}{{^required}}USE_DEFAULTS{{/required}})
99
{{#withXml}}
1010
@JacksonXmlProperty(localName = "{{items.xmlName}}{{^items.xmlName}}{{xmlName}}{{^xmlName}}{{baseName}}{{/xmlName}}{{/items.xmlName}}"{{#isXmlAttribute}}, isAttribute = true{{/isXmlAttribute}}{{#xmlNamespace}}, namespace = "{{.}}"{{/xmlNamespace}})

modules/openapi-generator/src/main/resources/Java/pojo.mustache

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ public class {{classname}} {{#parent}}extends {{{.}}} {{/parent}}{{#vendorExtens
115115
{{#jsonb}}@JsonbCreator{{/jsonb}}{{#jackson}}@JsonCreator{{/jackson}}
116116
public {{classname}}(
117117
{{#readOnlyVars}}
118-
{{#jsonb}}@JsonbProperty(value = "{{baseName}}"{{^required}}, nullable = true{{/required}}){{/jsonb}}{{#jackson}}@JsonProperty(value = JSON_PROPERTY_{{nameInSnakeCase}}, required = {{required}}){{/jackson}} {{{datatypeWithEnum}}} {{name}}{{^-last}}, {{/-last}}
118+
{{#jsonb}}@JsonbProperty(value = "{{baseName}}"{{^required}}, nullable = true{{/required}}){{/jsonb}}{{#jackson}}@JsonProperty(value = JSON_PROPERTY_{{nameInSnakeCase}}, required = {{#isNullable}}false{{/isNullable}}{{^isNullable}}{{required}}{{/isNullable}}){{/jackson}} {{{datatypeWithEnum}}} {{name}}{{^-last}}, {{/-last}}
119119
{{/readOnlyVars}}
120120
) {
121121
this();
@@ -130,7 +130,7 @@ public class {{classname}} {{#parent}}extends {{{.}}} {{/parent}}{{#vendorExtens
130130
/**
131131
* Constructor with all args parameters
132132
*/
133-
public {{classname}}({{#vendorExtensions.x-java-all-args-constructor-vars}}{{#jsonb}}@JsonbProperty(value = "{{baseName}}"{{^required}}, nullable = true{{/required}}){{/jsonb}}{{#jackson}}@JsonProperty(value = JSON_PROPERTY_{{nameInSnakeCase}}, required = {{required}}){{/jackson}} {{{datatypeWithEnum}}} {{name}}{{^-last}}, {{/-last}}{{/vendorExtensions.x-java-all-args-constructor-vars}}) {
133+
public {{classname}}({{#vendorExtensions.x-java-all-args-constructor-vars}}{{#jsonb}}@JsonbProperty(value = "{{baseName}}"{{^required}}, nullable = true{{/required}}){{/jsonb}}{{#jackson}}@JsonProperty(value = JSON_PROPERTY_{{nameInSnakeCase}}, required = {{#isNullable}}false{{/isNullable}}{{^isNullable}}{{required}}{{/isNullable}}){{/jackson}} {{{datatypeWithEnum}}} {{name}}{{^-last}}, {{/-last}}{{/vendorExtensions.x-java-all-args-constructor-vars}}) {
134134
{{#parent}}
135135
super({{#parentVars}}{{name}}{{^-last}}, {{/-last}}{{/parentVars}});
136136
{{/parent}}
@@ -261,7 +261,7 @@ public class {{classname}} {{#parent}}extends {{{.}}} {{/parent}}{{#vendorExtens
261261
return {{name}};
262262
}
263263
{{/vendorExtensions.x-is-jackson-optional-nullable}}{{#vendorExtensions.x-is-jackson-optional-nullable}}
264-
@JsonProperty(value = JSON_PROPERTY_{{nameInSnakeCase}}, required = {{required}})
264+
@JsonProperty(value = JSON_PROPERTY_{{nameInSnakeCase}}, required = {{#isNullable}}false{{/isNullable}}{{^isNullable}}{{required}}{{/isNullable}})
265265
{{#isReadOnly}}private{{/isReadOnly}}{{^isReadOnly}}public{{/isReadOnly}} void {{setter}}_JsonNullable(JsonNullable<{{{datatypeWithEnum}}}> {{name}}) {
266266
{{! For getters/setters that have name differing from attribute name, we must include setter (albeit private) for jackson to be able to set the attribute}}
267267
this.{{name}} = {{name}};

samples/client/echo_api/java/restclient/src/main/java/org/openapitools/client/model/DefaultValue.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -320,7 +320,7 @@ public JsonNullable<List<String>> getArrayStringNullable_JsonNullable() {
320320
return arrayStringNullable;
321321
}
322322

323-
@JsonProperty(value = JSON_PROPERTY_ARRAY_STRING_NULLABLE, required = false)
323+
@JsonProperty(JSON_PROPERTY_ARRAY_STRING_NULLABLE)
324324
public void setArrayStringNullable_JsonNullable(JsonNullable<List<String>> arrayStringNullable) {
325325
this.arrayStringNullable = arrayStringNullable;
326326
}
@@ -365,7 +365,7 @@ public JsonNullable<List<String>> getArrayStringExtensionNullable_JsonNullable()
365365
return arrayStringExtensionNullable;
366366
}
367367

368-
@JsonProperty(value = JSON_PROPERTY_ARRAY_STRING_EXTENSION_NULLABLE, required = false)
368+
@JsonProperty(JSON_PROPERTY_ARRAY_STRING_EXTENSION_NULLABLE)
369369
public void setArrayStringExtensionNullable_JsonNullable(JsonNullable<List<String>> arrayStringExtensionNullable) {
370370
this.arrayStringExtensionNullable = arrayStringExtensionNullable;
371371
}
@@ -398,7 +398,7 @@ public JsonNullable<String> getStringNullable_JsonNullable() {
398398
return stringNullable;
399399
}
400400

401-
@JsonProperty(value = JSON_PROPERTY_STRING_NULLABLE, required = false)
401+
@JsonProperty(JSON_PROPERTY_STRING_NULLABLE)
402402
public void setStringNullable_JsonNullable(JsonNullable<String> stringNullable) {
403403
this.stringNullable = stringNullable;
404404
}

samples/client/others/java/restclient-enum-in-multipart/src/main/java/org/openapitools/client/model/InlineObject.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,15 +52,15 @@ public InlineObject messageId(@jakarta.annotation.Nonnull UUID messageId) {
5252
* @return messageId
5353
*/
5454
@jakarta.annotation.Nonnull
55-
@JsonProperty(JSON_PROPERTY_MESSAGE_ID)
55+
@JsonProperty(value = JSON_PROPERTY_MESSAGE_ID, required = true)
5656
@JsonInclude(value = JsonInclude.Include.ALWAYS)
5757

5858
public UUID getMessageId() {
5959
return messageId;
6060
}
6161

6262

63-
@JsonProperty(JSON_PROPERTY_MESSAGE_ID)
63+
@JsonProperty(value = JSON_PROPERTY_MESSAGE_ID, required = true)
6464
@JsonInclude(value = JsonInclude.Include.ALWAYS)
6565
public void setMessageId(@jakarta.annotation.Nonnull UUID messageId) {
6666
this.messageId = messageId;

samples/client/others/java/webclient-sealedInterface/src/main/java/org/openapitools/client/model/Addressable.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -55,15 +55,15 @@ public Addressable href(@javax.annotation.Nullable String href) {
5555
* @return href
5656
*/
5757
@javax.annotation.Nullable
58-
@JsonProperty(JSON_PROPERTY_HREF)
58+
@JsonProperty(value = JSON_PROPERTY_HREF, required = false)
5959
@JsonInclude(value = JsonInclude.Include.USE_DEFAULTS)
6060

6161
public String getHref() {
6262
return href;
6363
}
6464

6565

66-
@JsonProperty(JSON_PROPERTY_HREF)
66+
@JsonProperty(value = JSON_PROPERTY_HREF, required = false)
6767
@JsonInclude(value = JsonInclude.Include.USE_DEFAULTS)
6868
public void setHref(@javax.annotation.Nullable String href) {
6969
this.href = href;
@@ -80,15 +80,15 @@ public Addressable id(@javax.annotation.Nullable String id) {
8080
* @return id
8181
*/
8282
@javax.annotation.Nullable
83-
@JsonProperty(JSON_PROPERTY_ID)
83+
@JsonProperty(value = JSON_PROPERTY_ID, required = false)
8484
@JsonInclude(value = JsonInclude.Include.USE_DEFAULTS)
8585

8686
public String getId() {
8787
return id;
8888
}
8989

9090

91-
@JsonProperty(JSON_PROPERTY_ID)
91+
@JsonProperty(value = JSON_PROPERTY_ID, required = false)
9292
@JsonInclude(value = JsonInclude.Include.USE_DEFAULTS)
9393
public void setId(@javax.annotation.Nullable String id) {
9494
this.id = id;

samples/client/others/java/webclient-sealedInterface/src/main/java/org/openapitools/client/model/Apple.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -58,15 +58,15 @@ public Apple seeds(@javax.annotation.Nonnull Integer seeds) {
5858
* @return seeds
5959
*/
6060
@javax.annotation.Nonnull
61-
@JsonProperty(JSON_PROPERTY_SEEDS)
61+
@JsonProperty(value = JSON_PROPERTY_SEEDS, required = true)
6262
@JsonInclude(value = JsonInclude.Include.ALWAYS)
6363

6464
public Integer getSeeds() {
6565
return seeds;
6666
}
6767

6868

69-
@JsonProperty(JSON_PROPERTY_SEEDS)
69+
@JsonProperty(value = JSON_PROPERTY_SEEDS, required = true)
7070
@JsonInclude(value = JsonInclude.Include.ALWAYS)
7171
public void setSeeds(@javax.annotation.Nonnull Integer seeds) {
7272
this.seeds = seeds;
@@ -83,15 +83,15 @@ public Apple fruitType(@javax.annotation.Nonnull FruitType fruitType) {
8383
* @return fruitType
8484
*/
8585
@javax.annotation.Nonnull
86-
@JsonProperty(JSON_PROPERTY_FRUIT_TYPE)
86+
@JsonProperty(value = JSON_PROPERTY_FRUIT_TYPE, required = true)
8787
@JsonInclude(value = JsonInclude.Include.ALWAYS)
8888

8989
public FruitType getFruitType() {
9090
return fruitType;
9191
}
9292

9393

94-
@JsonProperty(JSON_PROPERTY_FRUIT_TYPE)
94+
@JsonProperty(value = JSON_PROPERTY_FRUIT_TYPE, required = true)
9595
@JsonInclude(value = JsonInclude.Include.ALWAYS)
9696
public void setFruitType(@javax.annotation.Nonnull FruitType fruitType) {
9797
this.fruitType = fruitType;

samples/client/others/java/webclient-sealedInterface/src/main/java/org/openapitools/client/model/Banana.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -58,15 +58,15 @@ public Banana length(@javax.annotation.Nonnull Integer length) {
5858
* @return length
5959
*/
6060
@javax.annotation.Nonnull
61-
@JsonProperty(JSON_PROPERTY_LENGTH)
61+
@JsonProperty(value = JSON_PROPERTY_LENGTH, required = true)
6262
@JsonInclude(value = JsonInclude.Include.ALWAYS)
6363

6464
public Integer getLength() {
6565
return length;
6666
}
6767

6868

69-
@JsonProperty(JSON_PROPERTY_LENGTH)
69+
@JsonProperty(value = JSON_PROPERTY_LENGTH, required = true)
7070
@JsonInclude(value = JsonInclude.Include.ALWAYS)
7171
public void setLength(@javax.annotation.Nonnull Integer length) {
7272
this.length = length;
@@ -83,15 +83,15 @@ public Banana fruitType(@javax.annotation.Nonnull FruitType fruitType) {
8383
* @return fruitType
8484
*/
8585
@javax.annotation.Nonnull
86-
@JsonProperty(JSON_PROPERTY_FRUIT_TYPE)
86+
@JsonProperty(value = JSON_PROPERTY_FRUIT_TYPE, required = true)
8787
@JsonInclude(value = JsonInclude.Include.ALWAYS)
8888

8989
public FruitType getFruitType() {
9090
return fruitType;
9191
}
9292

9393

94-
@JsonProperty(JSON_PROPERTY_FRUIT_TYPE)
94+
@JsonProperty(value = JSON_PROPERTY_FRUIT_TYPE, required = true)
9595
@JsonInclude(value = JsonInclude.Include.ALWAYS)
9696
public void setFruitType(@javax.annotation.Nonnull FruitType fruitType) {
9797
this.fruitType = fruitType;

samples/client/others/java/webclient-sealedInterface/src/main/java/org/openapitools/client/model/Bar.java

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -77,15 +77,15 @@ public Bar id(@javax.annotation.Nonnull String id) {
7777
* @return id
7878
*/
7979
@javax.annotation.Nonnull
80-
@JsonProperty(JSON_PROPERTY_ID)
80+
@JsonProperty(value = JSON_PROPERTY_ID, required = true)
8181
@JsonInclude(value = JsonInclude.Include.ALWAYS)
8282

8383
public String getId() {
8484
return id;
8585
}
8686

8787

88-
@JsonProperty(JSON_PROPERTY_ID)
88+
@JsonProperty(value = JSON_PROPERTY_ID, required = true)
8989
@JsonInclude(value = JsonInclude.Include.ALWAYS)
9090
public void setId(@javax.annotation.Nonnull String id) {
9191
this.id = id;
@@ -102,15 +102,15 @@ public Bar barPropA(@javax.annotation.Nullable String barPropA) {
102102
* @return barPropA
103103
*/
104104
@javax.annotation.Nullable
105-
@JsonProperty(JSON_PROPERTY_BAR_PROP_A)
105+
@JsonProperty(value = JSON_PROPERTY_BAR_PROP_A, required = false)
106106
@JsonInclude(value = JsonInclude.Include.USE_DEFAULTS)
107107

108108
public String getBarPropA() {
109109
return barPropA;
110110
}
111111

112112

113-
@JsonProperty(JSON_PROPERTY_BAR_PROP_A)
113+
@JsonProperty(value = JSON_PROPERTY_BAR_PROP_A, required = false)
114114
@JsonInclude(value = JsonInclude.Include.USE_DEFAULTS)
115115
public void setBarPropA(@javax.annotation.Nullable String barPropA) {
116116
this.barPropA = barPropA;
@@ -127,15 +127,15 @@ public Bar fooPropB(@javax.annotation.Nullable String fooPropB) {
127127
* @return fooPropB
128128
*/
129129
@javax.annotation.Nullable
130-
@JsonProperty(JSON_PROPERTY_FOO_PROP_B)
130+
@JsonProperty(value = JSON_PROPERTY_FOO_PROP_B, required = false)
131131
@JsonInclude(value = JsonInclude.Include.USE_DEFAULTS)
132132

133133
public String getFooPropB() {
134134
return fooPropB;
135135
}
136136

137137

138-
@JsonProperty(JSON_PROPERTY_FOO_PROP_B)
138+
@JsonProperty(value = JSON_PROPERTY_FOO_PROP_B, required = false)
139139
@JsonInclude(value = JsonInclude.Include.USE_DEFAULTS)
140140
public void setFooPropB(@javax.annotation.Nullable String fooPropB) {
141141
this.fooPropB = fooPropB;
@@ -152,15 +152,15 @@ public Bar foo(@javax.annotation.Nullable FooRefOrValue foo) {
152152
* @return foo
153153
*/
154154
@javax.annotation.Nullable
155-
@JsonProperty(JSON_PROPERTY_FOO)
155+
@JsonProperty(value = JSON_PROPERTY_FOO, required = false)
156156
@JsonInclude(value = JsonInclude.Include.USE_DEFAULTS)
157157

158158
public FooRefOrValue getFoo() {
159159
return foo;
160160
}
161161

162162

163-
@JsonProperty(JSON_PROPERTY_FOO)
163+
@JsonProperty(value = JSON_PROPERTY_FOO, required = false)
164164
@JsonInclude(value = JsonInclude.Include.USE_DEFAULTS)
165165
public void setFoo(@javax.annotation.Nullable FooRefOrValue foo) {
166166
this.foo = foo;

samples/client/others/java/webclient-sealedInterface/src/main/java/org/openapitools/client/model/BarCreate.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -73,15 +73,15 @@ public BarCreate barPropA(@javax.annotation.Nullable String barPropA) {
7373
* @return barPropA
7474
*/
7575
@javax.annotation.Nullable
76-
@JsonProperty(JSON_PROPERTY_BAR_PROP_A)
76+
@JsonProperty(value = JSON_PROPERTY_BAR_PROP_A, required = false)
7777
@JsonInclude(value = JsonInclude.Include.USE_DEFAULTS)
7878

7979
public String getBarPropA() {
8080
return barPropA;
8181
}
8282

8383

84-
@JsonProperty(JSON_PROPERTY_BAR_PROP_A)
84+
@JsonProperty(value = JSON_PROPERTY_BAR_PROP_A, required = false)
8585
@JsonInclude(value = JsonInclude.Include.USE_DEFAULTS)
8686
public void setBarPropA(@javax.annotation.Nullable String barPropA) {
8787
this.barPropA = barPropA;
@@ -98,15 +98,15 @@ public BarCreate fooPropB(@javax.annotation.Nullable String fooPropB) {
9898
* @return fooPropB
9999
*/
100100
@javax.annotation.Nullable
101-
@JsonProperty(JSON_PROPERTY_FOO_PROP_B)
101+
@JsonProperty(value = JSON_PROPERTY_FOO_PROP_B, required = false)
102102
@JsonInclude(value = JsonInclude.Include.USE_DEFAULTS)
103103

104104
public String getFooPropB() {
105105
return fooPropB;
106106
}
107107

108108

109-
@JsonProperty(JSON_PROPERTY_FOO_PROP_B)
109+
@JsonProperty(value = JSON_PROPERTY_FOO_PROP_B, required = false)
110110
@JsonInclude(value = JsonInclude.Include.USE_DEFAULTS)
111111
public void setFooPropB(@javax.annotation.Nullable String fooPropB) {
112112
this.fooPropB = fooPropB;
@@ -123,15 +123,15 @@ public BarCreate foo(@javax.annotation.Nullable FooRefOrValue foo) {
123123
* @return foo
124124
*/
125125
@javax.annotation.Nullable
126-
@JsonProperty(JSON_PROPERTY_FOO)
126+
@JsonProperty(value = JSON_PROPERTY_FOO, required = false)
127127
@JsonInclude(value = JsonInclude.Include.USE_DEFAULTS)
128128

129129
public FooRefOrValue getFoo() {
130130
return foo;
131131
}
132132

133133

134-
@JsonProperty(JSON_PROPERTY_FOO)
134+
@JsonProperty(value = JSON_PROPERTY_FOO, required = false)
135135
@JsonInclude(value = JsonInclude.Include.USE_DEFAULTS)
136136
public void setFoo(@javax.annotation.Nullable FooRefOrValue foo) {
137137
this.foo = foo;

0 commit comments

Comments
 (0)