Remove the option to support JDK7 from Java generator and templates (#11547)

* remove java8 from java client generator and templates

* update tests

* remove threetenbp

* update spring templates to remove java8

* remove java8 from jaxrs template

* fix jaxrs spec

* fix feign

* remove CustomInstantDeserializer.java

* fix jersey1

* fix undertow

* various update

* fix jaxrs jersey1

* fix java inflector

* fix jaxrs cxf

* add new files

* update doc
This commit is contained in:
William Cheng
2022-02-10 10:35:29 +08:00
committed by GitHub
parent 441c069177
commit 8455c1cd23
843 changed files with 2790 additions and 6834 deletions

View File

@@ -12,7 +12,7 @@ This spec is mainly for testing Petstore server and contains fake endpoints, mod
## Requirements
Building the API client library requires:
1. Java 1.7+
1. Java 1.8+
2. Maven (3.8.3+)/Gradle (7.2+)
## Installation

View File

@@ -117,7 +117,6 @@ dependencies {
implementation 'org.openapitools:jackson-databind-nullable:0.2.1'
implementation group: 'org.apache.oltu.oauth2', name: 'org.apache.oltu.oauth2.client', version: '1.0.1'
implementation group: 'org.apache.commons', name: 'commons-lang3', version: '3.10'
implementation 'org.threeten:threetenbp:1.4.3'
implementation 'io.swagger.parser.v3:swagger-parser-v3:2.0.23'
implementation "jakarta.annotation:jakarta.annotation-api:$jakarta_annotation_version"
testImplementation 'junit:junit:4.13.1'

View File

@@ -18,7 +18,6 @@ lazy val root = (project in file(".")).
"javax.ws.rs" % "javax.ws.rs-api" % "2.0",
"org.openapitools" % "jackson-databind-nullable" % "0.2.2",
"org.apache.oltu.oauth2" % "org.apache.oltu.oauth2.client" % "1.0.1",
"org.threeten" % "threetenbp" % "1.4.3" % "compile",
"io.swagger.parser.v3" % "swagger-parser-v3" "2.0.23" % "compile"
"io.gsonfire" % "gson-fire" % "1.8.3" % "compile",
"jakarta.annotation" % "jakarta.annotation-api" % "1.3.5" % "compile",

View File

@@ -290,11 +290,6 @@
<artifactId>commons-lang3</artifactId>
<version>${commons-lang3-version}</version>
</dependency>
<dependency>
<groupId>org.threeten</groupId>
<artifactId>threetenbp</artifactId>
<version>${threetenbp-version}</version>
</dependency>
<dependency>
<groupId>io.swagger.parser.v3</groupId>
<artifactId>swagger-parser-v3</artifactId>
@@ -345,7 +340,6 @@
<gson-version>2.8.8</gson-version>
<commons-lang3-version>3.12.0</commons-lang3-version>
<jackson-databind-nullable-version>0.2.2</jackson-databind-nullable-version>
<threetenbp-version>1.5.0</threetenbp-version>
<jakarta-annotation-version>1.3.5</jakarta-annotation-version>
<junit-version>4.13.2</junit-version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>

View File

@@ -27,9 +27,6 @@ import okhttp3.logging.HttpLoggingInterceptor.Level;
import okio.Buffer;
import okio.BufferedSink;
import okio.Okio;
import org.threeten.bp.LocalDate;
import org.threeten.bp.OffsetDateTime;
import org.threeten.bp.format.DateTimeFormatter;
import org.apache.oltu.oauth2.client.request.OAuthClientRequest.TokenRequestBuilder;
import org.apache.oltu.oauth2.common.message.types.GrantType;
@@ -52,6 +49,9 @@ import java.security.cert.CertificateException;
import java.security.cert.CertificateFactory;
import java.security.cert.X509Certificate;
import java.text.DateFormat;
import java.time.LocalDate;
import java.time.OffsetDateTime;
import java.time.format.DateTimeFormatter;
import java.util.*;
import java.util.Map.Entry;
import java.util.concurrent.TimeUnit;

View File

@@ -23,9 +23,6 @@ import com.google.gson.stream.JsonWriter;
import com.google.gson.JsonElement;
import io.gsonfire.GsonFireBuilder;
import io.gsonfire.TypeSelector;
import org.threeten.bp.LocalDate;
import org.threeten.bp.OffsetDateTime;
import org.threeten.bp.format.DateTimeFormatter;
import okio.ByteString;
@@ -35,6 +32,9 @@ import java.lang.reflect.Type;
import java.text.DateFormat;
import java.text.ParseException;
import java.text.ParsePosition;
import java.time.LocalDate;
import java.time.OffsetDateTime;
import java.time.format.DateTimeFormatter;
import java.util.Date;
import java.util.Locale;
import java.util.Map;

View File

@@ -34,8 +34,8 @@ import java.math.BigDecimal;
import org.openapitools.client.model.Client;
import java.io.File;
import org.openapitools.client.model.FileSchemaTestClass;
import org.threeten.bp.LocalDate;
import org.threeten.bp.OffsetDateTime;
import java.time.LocalDate;
import java.time.OffsetDateTime;
import org.openapitools.client.model.OuterComposite;
import org.openapitools.client.model.User;
import org.openapitools.client.model.XmlItem;

View File

@@ -30,7 +30,7 @@ import io.swagger.v3.oas.models.parameters.Parameter;
import java.io.IOException;
import org.threeten.bp.OffsetDateTime;
import java.time.OffsetDateTime;
import org.openapitools.client.model.User;
import java.lang.reflect.Type;

View File

@@ -107,7 +107,7 @@ public class AdditionalPropertiesClass {
public AdditionalPropertiesClass putMapStringItem(String key, String mapStringItem) {
if (this.mapString == null) {
this.mapString = new HashMap<String, String>();
this.mapString = new HashMap<>();
}
this.mapString.put(key, mapStringItem);
return this;
@@ -138,7 +138,7 @@ public class AdditionalPropertiesClass {
public AdditionalPropertiesClass putMapNumberItem(String key, BigDecimal mapNumberItem) {
if (this.mapNumber == null) {
this.mapNumber = new HashMap<String, BigDecimal>();
this.mapNumber = new HashMap<>();
}
this.mapNumber.put(key, mapNumberItem);
return this;
@@ -169,7 +169,7 @@ public class AdditionalPropertiesClass {
public AdditionalPropertiesClass putMapIntegerItem(String key, Integer mapIntegerItem) {
if (this.mapInteger == null) {
this.mapInteger = new HashMap<String, Integer>();
this.mapInteger = new HashMap<>();
}
this.mapInteger.put(key, mapIntegerItem);
return this;
@@ -200,7 +200,7 @@ public class AdditionalPropertiesClass {
public AdditionalPropertiesClass putMapBooleanItem(String key, Boolean mapBooleanItem) {
if (this.mapBoolean == null) {
this.mapBoolean = new HashMap<String, Boolean>();
this.mapBoolean = new HashMap<>();
}
this.mapBoolean.put(key, mapBooleanItem);
return this;
@@ -231,7 +231,7 @@ public class AdditionalPropertiesClass {
public AdditionalPropertiesClass putMapArrayIntegerItem(String key, List<Integer> mapArrayIntegerItem) {
if (this.mapArrayInteger == null) {
this.mapArrayInteger = new HashMap<String, List<Integer>>();
this.mapArrayInteger = new HashMap<>();
}
this.mapArrayInteger.put(key, mapArrayIntegerItem);
return this;
@@ -262,7 +262,7 @@ public class AdditionalPropertiesClass {
public AdditionalPropertiesClass putMapArrayAnytypeItem(String key, List<Object> mapArrayAnytypeItem) {
if (this.mapArrayAnytype == null) {
this.mapArrayAnytype = new HashMap<String, List<Object>>();
this.mapArrayAnytype = new HashMap<>();
}
this.mapArrayAnytype.put(key, mapArrayAnytypeItem);
return this;
@@ -293,7 +293,7 @@ public class AdditionalPropertiesClass {
public AdditionalPropertiesClass putMapMapStringItem(String key, Map<String, String> mapMapStringItem) {
if (this.mapMapString == null) {
this.mapMapString = new HashMap<String, Map<String, String>>();
this.mapMapString = new HashMap<>();
}
this.mapMapString.put(key, mapMapStringItem);
return this;
@@ -324,7 +324,7 @@ public class AdditionalPropertiesClass {
public AdditionalPropertiesClass putMapMapAnytypeItem(String key, Map<String, Object> mapMapAnytypeItem) {
if (this.mapMapAnytype == null) {
this.mapMapAnytype = new HashMap<String, Map<String, Object>>();
this.mapMapAnytype = new HashMap<>();
}
this.mapMapAnytype.put(key, mapMapAnytypeItem);
return this;

View File

@@ -66,7 +66,7 @@ public class ArrayOfArrayOfNumberOnly {
public ArrayOfArrayOfNumberOnly addArrayArrayNumberItem(List<BigDecimal> arrayArrayNumberItem) {
if (this.arrayArrayNumber == null) {
this.arrayArrayNumber = new ArrayList<List<BigDecimal>>();
this.arrayArrayNumber = new ArrayList<>();
}
this.arrayArrayNumber.add(arrayArrayNumberItem);
return this;

View File

@@ -66,7 +66,7 @@ public class ArrayOfNumberOnly {
public ArrayOfNumberOnly addArrayNumberItem(BigDecimal arrayNumberItem) {
if (this.arrayNumber == null) {
this.arrayNumber = new ArrayList<BigDecimal>();
this.arrayNumber = new ArrayList<>();
}
this.arrayNumber.add(arrayNumberItem);
return this;

View File

@@ -74,7 +74,7 @@ public class ArrayTest {
public ArrayTest addArrayOfStringItem(String arrayOfStringItem) {
if (this.arrayOfString == null) {
this.arrayOfString = new ArrayList<String>();
this.arrayOfString = new ArrayList<>();
}
this.arrayOfString.add(arrayOfStringItem);
return this;
@@ -105,7 +105,7 @@ public class ArrayTest {
public ArrayTest addArrayArrayOfIntegerItem(List<Long> arrayArrayOfIntegerItem) {
if (this.arrayArrayOfInteger == null) {
this.arrayArrayOfInteger = new ArrayList<List<Long>>();
this.arrayArrayOfInteger = new ArrayList<>();
}
this.arrayArrayOfInteger.add(arrayArrayOfIntegerItem);
return this;
@@ -136,7 +136,7 @@ public class ArrayTest {
public ArrayTest addArrayArrayOfModelItem(List<ReadOnlyFirst> arrayArrayOfModelItem) {
if (this.arrayArrayOfModel == null) {
this.arrayArrayOfModel = new ArrayList<List<ReadOnlyFirst>>();
this.arrayArrayOfModel = new ArrayList<>();
}
this.arrayArrayOfModel.add(arrayArrayOfModelItem);
return this;

View File

@@ -186,7 +186,7 @@ public class EnumArrays {
public EnumArrays addArrayEnumItem(ArrayEnumEnum arrayEnumItem) {
if (this.arrayEnum == null) {
this.arrayEnum = new ArrayList<ArrayEnumEnum>();
this.arrayEnum = new ArrayList<>();
}
this.arrayEnum.add(arrayEnumItem);
return this;

View File

@@ -93,7 +93,7 @@ public class FileSchemaTestClass {
public FileSchemaTestClass addFilesItem(ModelFile filesItem) {
if (this.files == null) {
this.files = new ArrayList<ModelFile>();
this.files = new ArrayList<>();
}
this.files.add(filesItem);
return this;

View File

@@ -25,9 +25,9 @@ import io.swagger.annotations.ApiModelProperty;
import java.io.File;
import java.io.IOException;
import java.math.BigDecimal;
import java.time.LocalDate;
import java.time.OffsetDateTime;
import java.util.UUID;
import org.threeten.bp.LocalDate;
import org.threeten.bp.OffsetDateTime;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;

View File

@@ -125,7 +125,7 @@ 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 = new HashMap<>();
}
this.mapMapOfString.put(key, mapMapOfStringItem);
return this;
@@ -156,7 +156,7 @@ public class MapTest {
public MapTest putMapOfEnumStringItem(String key, InnerEnum mapOfEnumStringItem) {
if (this.mapOfEnumString == null) {
this.mapOfEnumString = new HashMap<String, InnerEnum>();
this.mapOfEnumString = new HashMap<>();
}
this.mapOfEnumString.put(key, mapOfEnumStringItem);
return this;
@@ -187,7 +187,7 @@ public class MapTest {
public MapTest putDirectMapItem(String key, Boolean directMapItem) {
if (this.directMap == null) {
this.directMap = new HashMap<String, Boolean>();
this.directMap = new HashMap<>();
}
this.directMap.put(key, directMapItem);
return this;
@@ -218,7 +218,7 @@ public class MapTest {
public MapTest putIndirectMapItem(String key, Boolean indirectMapItem) {
if (this.indirectMap == null) {
this.indirectMap = new HashMap<String, Boolean>();
this.indirectMap = new HashMap<>();
}
this.indirectMap.put(key, indirectMapItem);
return this;

View File

@@ -23,12 +23,12 @@ import com.google.gson.stream.JsonWriter;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import java.io.IOException;
import java.time.OffsetDateTime;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.UUID;
import org.openapitools.client.model.Animal;
import org.threeten.bp.OffsetDateTime;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
@@ -123,7 +123,7 @@ public class MixedPropertiesAndAdditionalPropertiesClass {
public MixedPropertiesAndAdditionalPropertiesClass putMapItem(String key, Animal mapItem) {
if (this.map == null) {
this.map = new HashMap<String, Animal>();
this.map = new HashMap<>();
}
this.map.put(key, mapItem);
return this;

View File

@@ -23,7 +23,7 @@ import com.google.gson.stream.JsonWriter;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import java.io.IOException;
import org.threeten.bp.OffsetDateTime;
import java.time.OffsetDateTime;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;

View File

@@ -68,7 +68,7 @@ public class Pet {
public static final String SERIALIZED_NAME_PHOTO_URLS = "photoUrls";
@SerializedName(SERIALIZED_NAME_PHOTO_URLS)
private Set<String> photoUrls = new LinkedHashSet<String>();
private Set<String> photoUrls = new LinkedHashSet<>();
public static final String SERIALIZED_NAME_TAGS = "tags";
@SerializedName(SERIALIZED_NAME_TAGS)
@@ -235,7 +235,7 @@ public class Pet {
public Pet addTagsItem(Tag tagsItem) {
if (this.tags == null) {
this.tags = new ArrayList<Tag>();
this.tags = new ArrayList<>();
}
this.tags.add(tagsItem);
return this;

View File

@@ -69,7 +69,7 @@ public class TypeHolderDefault {
public static final String SERIALIZED_NAME_ARRAY_ITEM = "array_item";
@SerializedName(SERIALIZED_NAME_ARRAY_ITEM)
private List<Integer> arrayItem = new ArrayList<Integer>();
private List<Integer> arrayItem = new ArrayList<>();
public TypeHolderDefault() {
}

View File

@@ -73,7 +73,7 @@ public class TypeHolderExample {
public static final String SERIALIZED_NAME_ARRAY_ITEM = "array_item";
@SerializedName(SERIALIZED_NAME_ARRAY_ITEM)
private List<Integer> arrayItem = new ArrayList<Integer>();
private List<Integer> arrayItem = new ArrayList<>();
public TypeHolderExample() {
}

View File

@@ -270,7 +270,7 @@ public class XmlItem {
public XmlItem addWrappedArrayItem(Integer wrappedArrayItem) {
if (this.wrappedArray == null) {
this.wrappedArray = new ArrayList<Integer>();
this.wrappedArray = new ArrayList<>();
}
this.wrappedArray.add(wrappedArrayItem);
return this;
@@ -393,7 +393,7 @@ public class XmlItem {
public XmlItem addNameArrayItem(Integer nameArrayItem) {
if (this.nameArray == null) {
this.nameArray = new ArrayList<Integer>();
this.nameArray = new ArrayList<>();
}
this.nameArray.add(nameArrayItem);
return this;
@@ -424,7 +424,7 @@ public class XmlItem {
public XmlItem addNameWrappedArrayItem(Integer nameWrappedArrayItem) {
if (this.nameWrappedArray == null) {
this.nameWrappedArray = new ArrayList<Integer>();
this.nameWrappedArray = new ArrayList<>();
}
this.nameWrappedArray.add(nameWrappedArrayItem);
return this;
@@ -547,7 +547,7 @@ public class XmlItem {
public XmlItem addPrefixArrayItem(Integer prefixArrayItem) {
if (this.prefixArray == null) {
this.prefixArray = new ArrayList<Integer>();
this.prefixArray = new ArrayList<>();
}
this.prefixArray.add(prefixArrayItem);
return this;
@@ -578,7 +578,7 @@ public class XmlItem {
public XmlItem addPrefixWrappedArrayItem(Integer prefixWrappedArrayItem) {
if (this.prefixWrappedArray == null) {
this.prefixWrappedArray = new ArrayList<Integer>();
this.prefixWrappedArray = new ArrayList<>();
}
this.prefixWrappedArray.add(prefixWrappedArrayItem);
return this;
@@ -701,7 +701,7 @@ public class XmlItem {
public XmlItem addNamespaceArrayItem(Integer namespaceArrayItem) {
if (this.namespaceArray == null) {
this.namespaceArray = new ArrayList<Integer>();
this.namespaceArray = new ArrayList<>();
}
this.namespaceArray.add(namespaceArrayItem);
return this;
@@ -732,7 +732,7 @@ public class XmlItem {
public XmlItem addNamespaceWrappedArrayItem(Integer namespaceWrappedArrayItem) {
if (this.namespaceWrappedArray == null) {
this.namespaceWrappedArray = new ArrayList<Integer>();
this.namespaceWrappedArray = new ArrayList<>();
}
this.namespaceWrappedArray.add(namespaceWrappedArrayItem);
return this;
@@ -855,7 +855,7 @@ public class XmlItem {
public XmlItem addPrefixNsArrayItem(Integer prefixNsArrayItem) {
if (this.prefixNsArray == null) {
this.prefixNsArray = new ArrayList<Integer>();
this.prefixNsArray = new ArrayList<>();
}
this.prefixNsArray.add(prefixNsArrayItem);
return this;
@@ -886,7 +886,7 @@ public class XmlItem {
public XmlItem addPrefixNsWrappedArrayItem(Integer prefixNsWrappedArrayItem) {
if (this.prefixNsWrappedArray == null) {
this.prefixNsWrappedArray = new ArrayList<Integer>();
this.prefixNsWrappedArray = new ArrayList<>();
}
this.prefixNsWrappedArray.add(prefixNsWrappedArrayItem);
return this;

View File

@@ -17,8 +17,8 @@ import java.util.TimeZone;
import okio.ByteString;
import org.junit.*;
import org.threeten.bp.LocalDate;
import org.threeten.bp.OffsetDateTime;
import java.time.LocalDate;
import java.time.OffsetDateTime;
import org.threeten.bp.ZoneId;
import org.threeten.bp.ZoneOffset;
import org.threeten.bp.format.DateTimeFormatter;

View File

@@ -18,8 +18,8 @@ import java.math.BigDecimal;
import org.openapitools.client.model.Client;
import java.io.File;
import org.openapitools.client.model.FileSchemaTestClass;
import org.threeten.bp.LocalDate;
import org.threeten.bp.OffsetDateTime;
import java.time.LocalDate;
import java.time.OffsetDateTime;
import org.openapitools.client.model.OuterComposite;
import org.openapitools.client.model.User;
import org.openapitools.client.model.XmlItem;

View File

@@ -24,8 +24,8 @@ import java.io.File;
import java.io.IOException;
import java.math.BigDecimal;
import java.util.UUID;
import org.threeten.bp.LocalDate;
import org.threeten.bp.OffsetDateTime;
import java.time.LocalDate;
import java.time.OffsetDateTime;
import org.junit.Assert;
import org.junit.Ignore;
import org.junit.Test;

View File

@@ -26,7 +26,7 @@ import java.util.List;
import java.util.Map;
import java.util.UUID;
import org.openapitools.client.model.Animal;
import org.threeten.bp.OffsetDateTime;
import java.time.OffsetDateTime;
import org.junit.Assert;
import org.junit.Ignore;
import org.junit.Test;

View File

@@ -21,7 +21,7 @@ import com.google.gson.stream.JsonWriter;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import java.io.IOException;
import org.threeten.bp.OffsetDateTime;
import java.time.OffsetDateTime;
import org.junit.Assert;
import org.junit.Ignore;
import org.junit.Test;