[Java] fix default value for JsonNullable (#14703)

* fix java webclient default value

* update default value in java okhttp client

* fix java native client default value in JsonNullable

* improve java okhttp-gson default value template

* update java rest-related templates

* update feign samples

* update jersey3 templates

* update jersey2 templates

* update default value in jaxrs templates

* fix spring default value

* update jaxrs pojo, fix tests

* update samples

* suport set
This commit is contained in:
William Cheng
2023-02-16 10:37:36 +08:00
committed by GitHub
parent 8b0b4b5d04
commit 71c2abf81c
230 changed files with 645 additions and 839 deletions

View File

@@ -35,10 +35,10 @@ import com.fasterxml.jackson.annotation.JsonTypeName;
@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen")
public class AdditionalPropertiesClass {
public static final String JSON_PROPERTY_MAP_PROPERTY = "map_property";
private Map<String, String> mapProperty = null;
private Map<String, String> mapProperty;
public static final String JSON_PROPERTY_MAP_OF_MAP_PROPERTY = "map_of_map_property";
private Map<String, Map<String, String>> mapOfMapProperty = null;
private Map<String, Map<String, String>> mapOfMapProperty;
public AdditionalPropertiesClass() {
}
@@ -50,9 +50,6 @@ public class AdditionalPropertiesClass {
}
public AdditionalPropertiesClass putMapPropertyItem(String key, String mapPropertyItem) {
if (this.mapProperty == null) {
this.mapProperty = null;
}
this.mapProperty.put(key, mapPropertyItem);
return this;
}
@@ -84,9 +81,6 @@ public class AdditionalPropertiesClass {
}
public AdditionalPropertiesClass putMapOfMapPropertyItem(String key, Map<String, String> mapOfMapPropertyItem) {
if (this.mapOfMapProperty == null) {
this.mapOfMapProperty = null;
}
this.mapOfMapProperty.put(key, mapOfMapPropertyItem);
return this;
}

View File

@@ -35,7 +35,7 @@ import com.fasterxml.jackson.annotation.JsonTypeName;
@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen")
public class ArrayOfArrayOfNumberOnly {
public static final String JSON_PROPERTY_ARRAY_ARRAY_NUMBER = "ArrayArrayNumber";
private List<List<BigDecimal>> arrayArrayNumber = null;
private List<List<BigDecimal>> arrayArrayNumber;
public ArrayOfArrayOfNumberOnly() {
}
@@ -47,9 +47,6 @@ public class ArrayOfArrayOfNumberOnly {
}
public ArrayOfArrayOfNumberOnly addArrayArrayNumberItem(List<BigDecimal> arrayArrayNumberItem) {
if (this.arrayArrayNumber == null) {
this.arrayArrayNumber = null;
}
this.arrayArrayNumber.add(arrayArrayNumberItem);
return this;
}

View File

@@ -35,7 +35,7 @@ import com.fasterxml.jackson.annotation.JsonTypeName;
@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen")
public class ArrayOfNumberOnly {
public static final String JSON_PROPERTY_ARRAY_NUMBER = "ArrayNumber";
private List<BigDecimal> arrayNumber = null;
private List<BigDecimal> arrayNumber;
public ArrayOfNumberOnly() {
}
@@ -47,9 +47,6 @@ public class ArrayOfNumberOnly {
}
public ArrayOfNumberOnly addArrayNumberItem(BigDecimal arrayNumberItem) {
if (this.arrayNumber == null) {
this.arrayNumber = null;
}
this.arrayNumber.add(arrayNumberItem);
return this;
}

View File

@@ -37,13 +37,13 @@ import com.fasterxml.jackson.annotation.JsonTypeName;
@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen")
public class ArrayTest {
public static final String JSON_PROPERTY_ARRAY_OF_STRING = "array_of_string";
private List<String> arrayOfString = null;
private List<String> arrayOfString;
public static final String JSON_PROPERTY_ARRAY_ARRAY_OF_INTEGER = "array_array_of_integer";
private List<List<Long>> arrayArrayOfInteger = null;
private List<List<Long>> arrayArrayOfInteger;
public static final String JSON_PROPERTY_ARRAY_ARRAY_OF_MODEL = "array_array_of_model";
private List<List<ReadOnlyFirst>> arrayArrayOfModel = null;
private List<List<ReadOnlyFirst>> arrayArrayOfModel;
public ArrayTest() {
}
@@ -55,9 +55,6 @@ public class ArrayTest {
}
public ArrayTest addArrayOfStringItem(String arrayOfStringItem) {
if (this.arrayOfString == null) {
this.arrayOfString = null;
}
this.arrayOfString.add(arrayOfStringItem);
return this;
}
@@ -89,9 +86,6 @@ public class ArrayTest {
}
public ArrayTest addArrayArrayOfIntegerItem(List<Long> arrayArrayOfIntegerItem) {
if (this.arrayArrayOfInteger == null) {
this.arrayArrayOfInteger = null;
}
this.arrayArrayOfInteger.add(arrayArrayOfIntegerItem);
return this;
}
@@ -123,9 +117,6 @@ public class ArrayTest {
}
public ArrayTest addArrayArrayOfModelItem(List<ReadOnlyFirst> arrayArrayOfModelItem) {
if (this.arrayArrayOfModel == null) {
this.arrayArrayOfModel = null;
}
this.arrayArrayOfModel.add(arrayArrayOfModelItem);
return this;
}

View File

@@ -108,7 +108,7 @@ public class EnumArrays {
}
public static final String JSON_PROPERTY_ARRAY_ENUM = "array_enum";
private List<ArrayEnumEnum> arrayEnum = null;
private List<ArrayEnumEnum> arrayEnum;
public EnumArrays() {
}
@@ -146,9 +146,6 @@ public class EnumArrays {
}
public EnumArrays addArrayEnumItem(ArrayEnumEnum arrayEnumItem) {
if (this.arrayEnum == null) {
this.arrayEnum = null;
}
this.arrayEnum.add(arrayEnumItem);
return this;
}

View File

@@ -39,7 +39,7 @@ public class FileSchemaTestClass {
private ModelFile _file;
public static final String JSON_PROPERTY_FILES = "files";
private List<ModelFile> files = null;
private List<ModelFile> files;
public FileSchemaTestClass() {
}
@@ -77,9 +77,6 @@ public class FileSchemaTestClass {
}
public FileSchemaTestClass addFilesItem(ModelFile filesItem) {
if (this.files == null) {
this.files = null;
}
this.files.add(filesItem);
return this;
}

View File

@@ -37,7 +37,7 @@ import com.fasterxml.jackson.annotation.JsonTypeName;
@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen")
public class MapTest {
public static final String JSON_PROPERTY_MAP_MAP_OF_STRING = "map_map_of_string";
private Map<String, Map<String, String>> mapMapOfString = null;
private Map<String, Map<String, String>> mapMapOfString;
/**
* Gets or Sets inner
@@ -75,13 +75,13 @@ public class MapTest {
}
public static final String JSON_PROPERTY_MAP_OF_ENUM_STRING = "map_of_enum_string";
private Map<String, InnerEnum> mapOfEnumString = null;
private Map<String, InnerEnum> mapOfEnumString;
public static final String JSON_PROPERTY_DIRECT_MAP = "direct_map";
private Map<String, Boolean> directMap = null;
private Map<String, Boolean> directMap;
public static final String JSON_PROPERTY_INDIRECT_MAP = "indirect_map";
private Map<String, Boolean> indirectMap = null;
private Map<String, Boolean> indirectMap;
public MapTest() {
}
@@ -93,9 +93,6 @@ public class MapTest {
}
public MapTest putMapMapOfStringItem(String key, Map<String, String> mapMapOfStringItem) {
if (this.mapMapOfString == null) {
this.mapMapOfString = null;
}
this.mapMapOfString.put(key, mapMapOfStringItem);
return this;
}
@@ -127,9 +124,6 @@ public class MapTest {
}
public MapTest putMapOfEnumStringItem(String key, InnerEnum mapOfEnumStringItem) {
if (this.mapOfEnumString == null) {
this.mapOfEnumString = null;
}
this.mapOfEnumString.put(key, mapOfEnumStringItem);
return this;
}
@@ -161,9 +155,6 @@ public class MapTest {
}
public MapTest putDirectMapItem(String key, Boolean directMapItem) {
if (this.directMap == null) {
this.directMap = null;
}
this.directMap.put(key, directMapItem);
return this;
}
@@ -195,9 +186,6 @@ public class MapTest {
}
public MapTest putIndirectMapItem(String key, Boolean indirectMapItem) {
if (this.indirectMap == null) {
this.indirectMap = null;
}
this.indirectMap.put(key, indirectMapItem);
return this;
}

View File

@@ -45,7 +45,7 @@ public class MixedPropertiesAndAdditionalPropertiesClass {
private OffsetDateTime dateTime;
public static final String JSON_PROPERTY_MAP = "map";
private Map<String, Animal> map = null;
private Map<String, Animal> map;
public MixedPropertiesAndAdditionalPropertiesClass() {
}
@@ -109,9 +109,6 @@ public class MixedPropertiesAndAdditionalPropertiesClass {
}
public MixedPropertiesAndAdditionalPropertiesClass putMapItem(String key, Animal mapItem) {
if (this.map == null) {
this.map = null;
}
this.map.put(key, mapItem);
return this;
}

View File

@@ -78,7 +78,7 @@ public class NullableClass extends HashMap<String, Object> {
private JsonNullable<List<Object>> arrayAndItemsNullableProp = JsonNullable.<List<Object>>undefined();
public static final String JSON_PROPERTY_ARRAY_ITEMS_NULLABLE = "array_items_nullable";
private List<Object> arrayItemsNullable = null;
private List<Object> arrayItemsNullable;
public static final String JSON_PROPERTY_OBJECT_NULLABLE_PROP = "object_nullable_prop";
private JsonNullable<Map<String, Object>> objectNullableProp = JsonNullable.<Map<String, Object>>undefined();
@@ -87,7 +87,7 @@ public class NullableClass extends HashMap<String, Object> {
private JsonNullable<Map<String, Object>> objectAndItemsNullableProp = JsonNullable.<Map<String, Object>>undefined();
public static final String JSON_PROPERTY_OBJECT_ITEMS_NULLABLE = "object_items_nullable";
private Map<String, Object> objectItemsNullable = null;
private Map<String, Object> objectItemsNullable;
public NullableClass() {
@@ -305,7 +305,7 @@ public class NullableClass extends HashMap<String, Object> {
public NullableClass addArrayNullablePropItem(Object arrayNullablePropItem) {
if (this.arrayNullableProp == null || !this.arrayNullableProp.isPresent()) {
this.arrayNullableProp = JsonNullable.<List<Object>>of(null);
this.arrayNullableProp = JsonNullable.<List<Object>>of(new ArrayList<>());
}
try {
this.arrayNullableProp.get().add(arrayNullablePropItem);
@@ -351,7 +351,7 @@ public class NullableClass extends HashMap<String, Object> {
public NullableClass addArrayAndItemsNullablePropItem(Object arrayAndItemsNullablePropItem) {
if (this.arrayAndItemsNullableProp == null || !this.arrayAndItemsNullableProp.isPresent()) {
this.arrayAndItemsNullableProp = JsonNullable.<List<Object>>of(null);
this.arrayAndItemsNullableProp = JsonNullable.<List<Object>>of(new ArrayList<>());
}
try {
this.arrayAndItemsNullableProp.get().add(arrayAndItemsNullablePropItem);
@@ -396,9 +396,6 @@ public class NullableClass extends HashMap<String, Object> {
}
public NullableClass addArrayItemsNullableItem(Object arrayItemsNullableItem) {
if (this.arrayItemsNullable == null) {
this.arrayItemsNullable = null;
}
this.arrayItemsNullable.add(arrayItemsNullableItem);
return this;
}
@@ -431,7 +428,7 @@ public class NullableClass extends HashMap<String, Object> {
public NullableClass putObjectNullablePropItem(String key, Object objectNullablePropItem) {
if (this.objectNullableProp == null || !this.objectNullableProp.isPresent()) {
this.objectNullableProp = JsonNullable.<Map<String, Object>>of(null);
this.objectNullableProp = JsonNullable.<Map<String, Object>>of(new HashMap<>());
}
try {
this.objectNullableProp.get().put(key, objectNullablePropItem);
@@ -477,7 +474,7 @@ public class NullableClass extends HashMap<String, Object> {
public NullableClass putObjectAndItemsNullablePropItem(String key, Object objectAndItemsNullablePropItem) {
if (this.objectAndItemsNullableProp == null || !this.objectAndItemsNullableProp.isPresent()) {
this.objectAndItemsNullableProp = JsonNullable.<Map<String, Object>>of(null);
this.objectAndItemsNullableProp = JsonNullable.<Map<String, Object>>of(new HashMap<>());
}
try {
this.objectAndItemsNullableProp.get().put(key, objectAndItemsNullablePropItem);
@@ -522,9 +519,6 @@ public class NullableClass extends HashMap<String, Object> {
}
public NullableClass putObjectItemsNullableItem(String key, Object objectItemsNullableItem) {
if (this.objectItemsNullable == null) {
this.objectItemsNullable = null;
}
this.objectItemsNullable.put(key, objectItemsNullableItem);
return this;
}

View File

@@ -48,7 +48,7 @@ public class ObjectWithDeprecatedFields {
private DeprecatedObject deprecatedRef;
public static final String JSON_PROPERTY_BARS = "bars";
private List<String> bars = null;
private List<String> bars;
public ObjectWithDeprecatedFields() {
}
@@ -142,9 +142,6 @@ public class ObjectWithDeprecatedFields {
}
public ObjectWithDeprecatedFields addBarsItem(String barsItem) {
if (this.bars == null) {
this.bars = null;
}
this.bars.add(barsItem);
return this;
}

View File

@@ -53,10 +53,10 @@ public class Pet {
private String name;
public static final String JSON_PROPERTY_PHOTO_URLS = "photoUrls";
private Set<String> photoUrls = null;
private Set<String> photoUrls;
public static final String JSON_PROPERTY_TAGS = "tags";
private List<Tag> tags = null;
private List<Tag> tags;
/**
* pet status in the store
@@ -218,9 +218,6 @@ public class Pet {
}
public Pet addTagsItem(Tag tagsItem) {
if (this.tags == null) {
this.tags = null;
}
this.tags.add(tagsItem);
return this;
}