forked from loafle/openapi-generator-original
Commit e3d04ee01 (issue #5240) introduced unsafe add/put methods for optional
list/map parameters. This change maintains the spirit of issue #5240 (optional
containers are null by default) while still making add/put calls safe. It does
this by checking for null first and, if so, initializing it with an empty
container.
Also updated the affected samples using the various scripts in bin/.
This commit is contained in:
committed by
wing328
parent
df1055fe38
commit
ab69ce5dc3
@@ -38,6 +38,9 @@ public class AdditionalPropertiesClass {
|
||||
}
|
||||
|
||||
public AdditionalPropertiesClass putMapPropertyItem(String key, String mapPropertyItem) {
|
||||
if (this.mapProperty == null) {
|
||||
this.mapProperty = new HashMap<String, String>();
|
||||
}
|
||||
this.mapProperty.put(key, mapPropertyItem);
|
||||
return this;
|
||||
}
|
||||
@@ -61,6 +64,9 @@ public class AdditionalPropertiesClass {
|
||||
}
|
||||
|
||||
public AdditionalPropertiesClass putMapOfMapPropertyItem(String key, Map<String, String> mapOfMapPropertyItem) {
|
||||
if (this.mapOfMapProperty == null) {
|
||||
this.mapOfMapProperty = new HashMap<String, Map<String, String>>();
|
||||
}
|
||||
this.mapOfMapProperty.put(key, mapOfMapPropertyItem);
|
||||
return this;
|
||||
}
|
||||
|
||||
@@ -35,6 +35,9 @@ public class ArrayOfArrayOfNumberOnly {
|
||||
}
|
||||
|
||||
public ArrayOfArrayOfNumberOnly addArrayArrayNumberItem(List<BigDecimal> arrayArrayNumberItem) {
|
||||
if (this.arrayArrayNumber == null) {
|
||||
this.arrayArrayNumber = new ArrayList<List<BigDecimal>>();
|
||||
}
|
||||
this.arrayArrayNumber.add(arrayArrayNumberItem);
|
||||
return this;
|
||||
}
|
||||
|
||||
@@ -35,6 +35,9 @@ public class ArrayOfNumberOnly {
|
||||
}
|
||||
|
||||
public ArrayOfNumberOnly addArrayNumberItem(BigDecimal arrayNumberItem) {
|
||||
if (this.arrayNumber == null) {
|
||||
this.arrayNumber = new ArrayList<BigDecimal>();
|
||||
}
|
||||
this.arrayNumber.add(arrayNumberItem);
|
||||
return this;
|
||||
}
|
||||
|
||||
@@ -41,6 +41,9 @@ public class ArrayTest {
|
||||
}
|
||||
|
||||
public ArrayTest addArrayOfStringItem(String arrayOfStringItem) {
|
||||
if (this.arrayOfString == null) {
|
||||
this.arrayOfString = new ArrayList<String>();
|
||||
}
|
||||
this.arrayOfString.add(arrayOfStringItem);
|
||||
return this;
|
||||
}
|
||||
@@ -64,6 +67,9 @@ public class ArrayTest {
|
||||
}
|
||||
|
||||
public ArrayTest addArrayArrayOfIntegerItem(List<Long> arrayArrayOfIntegerItem) {
|
||||
if (this.arrayArrayOfInteger == null) {
|
||||
this.arrayArrayOfInteger = new ArrayList<List<Long>>();
|
||||
}
|
||||
this.arrayArrayOfInteger.add(arrayArrayOfIntegerItem);
|
||||
return this;
|
||||
}
|
||||
@@ -87,6 +93,9 @@ public class ArrayTest {
|
||||
}
|
||||
|
||||
public ArrayTest addArrayArrayOfModelItem(List<ReadOnlyFirst> arrayArrayOfModelItem) {
|
||||
if (this.arrayArrayOfModel == null) {
|
||||
this.arrayArrayOfModel = new ArrayList<List<ReadOnlyFirst>>();
|
||||
}
|
||||
this.arrayArrayOfModel.add(arrayArrayOfModelItem);
|
||||
return this;
|
||||
}
|
||||
|
||||
@@ -99,6 +99,9 @@ public class EnumArrays {
|
||||
}
|
||||
|
||||
public EnumArrays addArrayEnumItem(ArrayEnumEnum arrayEnumItem) {
|
||||
if (this.arrayEnum == null) {
|
||||
this.arrayEnum = new ArrayList<ArrayEnumEnum>();
|
||||
}
|
||||
this.arrayEnum.add(arrayEnumItem);
|
||||
return this;
|
||||
}
|
||||
|
||||
@@ -60,6 +60,9 @@ public class MapTest {
|
||||
}
|
||||
|
||||
public MapTest putMapMapOfStringItem(String key, Map<String, String> mapMapOfStringItem) {
|
||||
if (this.mapMapOfString == null) {
|
||||
this.mapMapOfString = new HashMap<String, Map<String, String>>();
|
||||
}
|
||||
this.mapMapOfString.put(key, mapMapOfStringItem);
|
||||
return this;
|
||||
}
|
||||
@@ -83,6 +86,9 @@ public class MapTest {
|
||||
}
|
||||
|
||||
public MapTest putMapOfEnumStringItem(String key, InnerEnum mapOfEnumStringItem) {
|
||||
if (this.mapOfEnumString == null) {
|
||||
this.mapOfEnumString = new HashMap<String, InnerEnum>();
|
||||
}
|
||||
this.mapOfEnumString.put(key, mapOfEnumStringItem);
|
||||
return this;
|
||||
}
|
||||
|
||||
@@ -80,6 +80,9 @@ public class MixedPropertiesAndAdditionalPropertiesClass {
|
||||
}
|
||||
|
||||
public MixedPropertiesAndAdditionalPropertiesClass putMapItem(String key, Animal mapItem) {
|
||||
if (this.map == null) {
|
||||
this.map = new HashMap<String, Animal>();
|
||||
}
|
||||
this.map.put(key, mapItem);
|
||||
return this;
|
||||
}
|
||||
|
||||
@@ -153,6 +153,9 @@ public class Pet {
|
||||
}
|
||||
|
||||
public Pet addTagsItem(Tag tagsItem) {
|
||||
if (this.tags == null) {
|
||||
this.tags = new ArrayList<Tag>();
|
||||
}
|
||||
this.tags.add(tagsItem);
|
||||
return this;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user