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
@@ -386,7 +386,7 @@ public class {{classname}} {{#parent}}extends {{{.}}} {{/parent}}{{#vendorExtens
386
386
{{#items.isModel}}
387
387
{{#required}}
388
388
// ensure the json data is an array
389
-
if (!jsonObj.get("{{{baseName}}}").isJsonArray()) {
389
+
if (!jsonObj.get("{{{baseName}}}").isJsonArray(){{#isNullable}} && !jsonObj.get("{{baseName}}").isJsonNull(){{/isNullable}}) {
390
390
throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `{{{baseName}}}` to be an array in the JSON string but got `%s`", jsonObj.get("{{{baseName}}}").toString()));
391
391
}
392
392
@@ -424,7 +424,7 @@ public class {{classname}} {{#parent}}extends {{{.}}} {{/parent}}{{#vendorExtens
424
424
// ensure the required json array is present
425
425
if (jsonObj.get("{{{baseName}}}") == null) {
426
426
throw new IllegalArgumentException("Expected the field `linkedContent` to be an array in the JSON string but got `null`");
427
-
} else if (!jsonObj.get("{{{baseName}}}").isJsonArray()) {
427
+
} else if (!jsonObj.get("{{{baseName}}}").isJsonArray(){{#isNullable}} && !jsonObj.get("{{baseName}}").isJsonNull(){{/isNullable}}) {
428
428
throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `{{{baseName}}}` to be an array in the JSON string but got `%s`", jsonObj.get("{{{baseName}}}").toString()));
429
429
}
430
430
{{/required}}
@@ -438,8 +438,14 @@ public class {{classname}} {{#parent}}extends {{{.}}} {{/parent}}{{#vendorExtens
438
438
{{/isString}}
439
439
{{#isModel}}
440
440
{{#required}}
441
+
{{#isNullable}}
442
+
if (jsonObj.get("{{{baseName}}}") != null && !jsonObj.get("{{{baseName}}}").isJsonNull()) {
0 commit comments