File tree Expand file tree Collapse file tree
modules/openapi-generator/src/main/resources/JavaSpring
samples/server/petstore/spring-boot-nullable-set/src/main/java/org/openapitools/model Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -96,7 +96,7 @@ public class {{classname}}{{#parent}} extends {{{parent}}}{{/parent}}{{^parent}}
9696 {{#openApiNullable} }
9797 { {^required} }
9898 if (this.{ {name} } == null{ {#isNullable} } || !this.{ {name} }.isPresent(){ {/isNullable} }) {
99- this.{{name} } = { {#isNullable} }JsonNullable.of({ {{ defaultValue} }}) { {/isNullable } }{ {^isNullable } } { {{ defaultValue} }} { {/isNullable} };
99+ this.{{name} } = { {#isNullable} }JsonNullable.of({ {/isNullable } } { {{ defaultValue} }}{ {^defaultValue } }new { {#uniqueItems } }LinkedHashSet { {/uniqueItems } }{ {^uniqueItems } }ArrayList { {/uniqueItems } } <> () { {/ defaultValue} }{ {#isNullable } }) { {/isNullable} };
100100 }
101101 { {/required} }
102102 this.{ {name} }{ {#isNullable} }.get(){ {/isNullable} }.add({ {name} }Item);
@@ -115,7 +115,7 @@ public class {{classname}}{{#parent}} extends {{{parent}}}{{/parent}}{{^parent}}
115115 public { {classname} } put{ {nameInCamelCase} }Item(String key, { {{items.datatypeWithEnum} }} { {name} }Item) {
116116 {{^required} }
117117 if (this.{ {name} } == null) {
118- this.{{name} } = { {{defaultValue} }};
118+ this.{{name} } = { {{defaultValue} }}{ {^defaultValue } }new HashMap <> () { {/defaultValue } } ;
119119 }
120120 { {/required} }
121121 this.{ {name} }.put(key, { {name} }Item);
Original file line number Diff line number Diff line change @@ -62,7 +62,7 @@ public ObjectWithUniqueItems nullSet(Set<String> nullSet) {
6262
6363 public ObjectWithUniqueItems addNullSetItem (String nullSetItem ) {
6464 if (this .nullSet == null || !this .nullSet .isPresent ()) {
65- this .nullSet = JsonNullable .of (null );
65+ this .nullSet = JsonNullable .of (new LinkedHashSet <>() );
6666 }
6767 this .nullSet .get ().add (nullSetItem );
6868 return this ;
@@ -117,7 +117,7 @@ public ObjectWithUniqueItems nullList(List<String> nullList) {
117117
118118 public ObjectWithUniqueItems addNullListItem (String nullListItem ) {
119119 if (this .nullList == null || !this .nullList .isPresent ()) {
120- this .nullList = JsonNullable .of (null );
120+ this .nullList = JsonNullable .of (new ArrayList <>() );
121121 }
122122 this .nullList .get ().add (nullListItem );
123123 return this ;
You can’t perform that action at this time.
0 commit comments