You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: modules/openapi-generator/src/main/resources/Java/libraries/okhttp-gson/pojo.mustache
+20-2Lines changed: 20 additions & 2 deletions
Original file line number
Diff line number
Diff line change
@@ -398,7 +398,7 @@ public class {{classname}} {{#parent}}extends {{{.}}} {{/parent}}{{#vendorExtens
398
398
{{#items.isModel}}
399
399
{{#required}}
400
400
// ensure the json data is an array
401
-
if (!jsonObj.get("{{{baseName}}}").isJsonArray()) {
401
+
if (!jsonObj.get("{{{baseName}}}").isJsonArray(){{#isNullable}} && !jsonObj.get("{{baseName}}").isJsonNull(){{/isNullable}}) {
402
402
throw new IllegalArgumentException(String.format("Expected the field `{{{baseName}}}` to be an array in the JSON string but got `%s`", jsonObj.get("{{{baseName}}}").toString()));
403
403
}
404
404
@@ -436,7 +436,7 @@ public class {{classname}} {{#parent}}extends {{{.}}} {{/parent}}{{#vendorExtens
436
436
// ensure the required json array is present
437
437
if (jsonObj.get("{{{baseName}}}") == null) {
438
438
throw new IllegalArgumentException("Expected the field `linkedContent` to be an array in the JSON string but got `null`");
439
-
} else if (!jsonObj.get("{{{baseName}}}").isJsonArray()) {
439
+
} else if (!jsonObj.get("{{{baseName}}}").isJsonArray(){{#isNullable}} && !jsonObj.get("{{baseName}}").isJsonNull(){{/isNullable}}) {
440
440
throw new IllegalArgumentException(String.format("Expected the field `{{{baseName}}}` to be an array in the JSON string but got `%s`", jsonObj.get("{{{baseName}}}").toString()));
441
441
}
442
442
{{/required}}
@@ -450,8 +450,14 @@ public class {{classname}} {{#parent}}extends {{{.}}} {{/parent}}{{#vendorExtens
450
450
{{/isString}}
451
451
{{#isModel}}
452
452
{{#required}}
453
+
{{#isNullable}}
454
+
if (jsonObj.get("{{{baseName}}}") != null && !jsonObj.get("{{{baseName}}}").isJsonNull()) {
0 commit comments