From ff0d4eb8d711d7d0017f8e05a42e20f94b1f2440 Mon Sep 17 00:00:00 2001 From: tanmen Date: Thu, 18 Apr 2019 12:05:18 +0900 Subject: [PATCH] Add nullable array support in spring (#2660) * Add nullable support in spring * fix forgot unescape defaultValue * Fix syntax error --- .../src/main/resources/JavaSpring/pojo.mustache | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/modules/openapi-generator/src/main/resources/JavaSpring/pojo.mustache b/modules/openapi-generator/src/main/resources/JavaSpring/pojo.mustache index 26754d33db2..29c35fbc1d7 100644 --- a/modules/openapi-generator/src/main/resources/JavaSpring/pojo.mustache +++ b/modules/openapi-generator/src/main/resources/JavaSpring/pojo.mustache @@ -44,11 +44,11 @@ public class {{classname}} {{#parent}}extends {{{parent}}}{{/parent}}{{^parent}} public {{classname}} add{{nameInCamelCase}}Item({{{items.datatypeWithEnum}}} {{name}}Item) { {{^required}} - if (this.{{name}} == null) { - this.{{name}} = {{{defaultValue}}}; + if (this.{{name}} == null{{#isNullable}} || !this.{{name}}.isPresent(){{/isNullable}}) { + this.{{name}} = {{#isNullable}}JsonNullable.of({{{defaultValue}}}){{/isNullable}}{{^isNullable}}{{{defaultValue}}}{{/isNullable}}; } {{/required}} - this.{{name}}.add({{name}}Item); + this.{{name}}{{#isNullable}}.get(){{/isNullable}}.add({{name}}Item); return this; } {{/isListContainer}}