forked from loafle/openapi-generator-original
Switch to Java 8 (#124)
* Set java version 1.8 * Remove "joda-time" usage * Remove 'com.google.common.base.Function' usage * Remove "LinkedListMultimap" usage * Add guava to the dependencies
This commit is contained in:
parent
186594115f
commit
ca89af8080
@ -74,8 +74,8 @@
|
|||||||
<artifactId>maven-compiler-plugin</artifactId>
|
<artifactId>maven-compiler-plugin</artifactId>
|
||||||
<version>3.5.1</version>
|
<version>3.5.1</version>
|
||||||
<configuration>
|
<configuration>
|
||||||
<source>1.7</source>
|
<source>1.8</source>
|
||||||
<target>1.7</target>
|
<target>1.8</target>
|
||||||
</configuration>
|
</configuration>
|
||||||
</plugin>
|
</plugin>
|
||||||
<plugin>
|
<plugin>
|
||||||
@ -195,6 +195,7 @@
|
|||||||
</reporting>
|
</reporting>
|
||||||
<properties>
|
<properties>
|
||||||
<diffutils-version>1.3.0</diffutils-version>
|
<diffutils-version>1.3.0</diffutils-version>
|
||||||
|
<guava-version>20.0</guava-version>
|
||||||
</properties>
|
</properties>
|
||||||
<dependencies>
|
<dependencies>
|
||||||
<dependency>
|
<dependency>
|
||||||
@ -257,6 +258,11 @@
|
|||||||
<artifactId>commons-cli</artifactId>
|
<artifactId>commons-cli</artifactId>
|
||||||
<version>${commons-cli-version}</version>
|
<version>${commons-cli-version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.google.guava</groupId>
|
||||||
|
<artifactId>guava</artifactId>
|
||||||
|
<version>${guava-version}</version>
|
||||||
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.testng</groupId>
|
<groupId>org.testng</groupId>
|
||||||
<artifactId>testng</artifactId>
|
<artifactId>testng</artifactId>
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
package org.openapitools.codegen;
|
package org.openapitools.codegen;
|
||||||
|
|
||||||
import javax.annotation.Nullable;
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
@ -8,10 +7,9 @@ import java.util.LinkedHashMap;
|
|||||||
import java.util.Map.Entry;
|
import java.util.Map.Entry;
|
||||||
import java.util.regex.Matcher;
|
import java.util.regex.Matcher;
|
||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||||
import com.google.common.base.Function;
|
|
||||||
import com.google.common.collect.Lists;
|
|
||||||
import com.samskivert.mustache.Mustache.Compiler;
|
import com.samskivert.mustache.Mustache.Compiler;
|
||||||
|
|
||||||
import io.swagger.models.Model;
|
import io.swagger.models.Model;
|
||||||
@ -3208,13 +3206,9 @@ public class DefaultCodegen implements CodegenConfig {
|
|||||||
* @return camelized string
|
* @return camelized string
|
||||||
*/
|
*/
|
||||||
protected String removeNonNameElementToCamelCase(final String name, final String nonNameElementPattern) {
|
protected String removeNonNameElementToCamelCase(final String name, final String nonNameElementPattern) {
|
||||||
String result = StringUtils.join(Lists.transform(Lists.newArrayList(name.split(nonNameElementPattern)), new Function<String, String>() {
|
String result = Arrays.stream(name.split(nonNameElementPattern))
|
||||||
@Nullable
|
.map(StringUtils::capitalize)
|
||||||
@Override
|
.collect(Collectors.joining(""));
|
||||||
public String apply(String input) {
|
|
||||||
return StringUtils.capitalize(input);
|
|
||||||
}
|
|
||||||
}), "");
|
|
||||||
if (result.length() > 0) {
|
if (result.length() > 0) {
|
||||||
result = result.substring(0, 1).toLowerCase() + result.substring(1);
|
result = result.substring(0, 1).toLowerCase() + result.substring(1);
|
||||||
}
|
}
|
||||||
|
@ -20,7 +20,6 @@ import io.swagger.v3.oas.models.tags.Tag;
|
|||||||
import org.apache.commons.io.IOUtils;
|
import org.apache.commons.io.IOUtils;
|
||||||
import org.apache.commons.lang3.ObjectUtils;
|
import org.apache.commons.lang3.ObjectUtils;
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import org.joda.time.DateTime;
|
|
||||||
import org.openapitools.codegen.ignore.CodegenIgnoreProcessor;
|
import org.openapitools.codegen.ignore.CodegenIgnoreProcessor;
|
||||||
//import org.openapitools.codegen.languages.AbstractJavaCodegen;
|
//import org.openapitools.codegen.languages.AbstractJavaCodegen;
|
||||||
import org.openapitools.codegen.utils.ImplementationVersion;
|
import org.openapitools.codegen.utils.ImplementationVersion;
|
||||||
@ -32,6 +31,7 @@ import org.slf4j.LoggerFactory;
|
|||||||
import java.io.*;
|
import java.io.*;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.net.*;
|
import java.net.*;
|
||||||
|
import java.time.ZonedDateTime;
|
||||||
|
|
||||||
public class DefaultGenerator extends AbstractGenerator implements Generator {
|
public class DefaultGenerator extends AbstractGenerator implements Generator {
|
||||||
protected final Logger LOGGER = LoggerFactory.getLogger(DefaultGenerator.class);
|
protected final Logger LOGGER = LoggerFactory.getLogger(DefaultGenerator.class);
|
||||||
@ -163,8 +163,8 @@ public class DefaultGenerator extends AbstractGenerator implements Generator {
|
|||||||
config.processOpts();
|
config.processOpts();
|
||||||
config.preprocessOpenAPI(openAPI);
|
config.preprocessOpenAPI(openAPI);
|
||||||
config.additionalProperties().put("generatorVersion", ImplementationVersion.read());
|
config.additionalProperties().put("generatorVersion", ImplementationVersion.read());
|
||||||
config.additionalProperties().put("generatedDate", DateTime.now().toString());
|
config.additionalProperties().put("generatedDate", ZonedDateTime.now().toString());
|
||||||
config.additionalProperties().put("generatedYear", String.valueOf(DateTime.now().getYear()));
|
config.additionalProperties().put("generatedYear", String.valueOf(ZonedDateTime.now().getYear()));
|
||||||
config.additionalProperties().put("generatorClass", config.getClass().getName());
|
config.additionalProperties().put("generatorClass", config.getClass().getName());
|
||||||
config.additionalProperties().put("inputSpec", config.getInputSpec());
|
config.additionalProperties().put("inputSpec", config.getInputSpec());
|
||||||
|
|
||||||
|
@ -2,8 +2,6 @@ package org.openapitools.codegen.languages;
|
|||||||
|
|
||||||
import static java.util.Collections.sort;
|
import static java.util.Collections.sort;
|
||||||
|
|
||||||
import com.google.common.collect.LinkedListMultimap;
|
|
||||||
|
|
||||||
import org.openapitools.codegen.*;
|
import org.openapitools.codegen.*;
|
||||||
import org.openapitools.codegen.languages.features.BeanValidationFeatures;
|
import org.openapitools.codegen.languages.features.BeanValidationFeatures;
|
||||||
import org.openapitools.codegen.languages.features.GzipFeatures;
|
import org.openapitools.codegen.languages.features.GzipFeatures;
|
||||||
@ -515,12 +513,12 @@ public class JavaClientCodegen extends AbstractJavaCodegen
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static List<Map<String, Object>> modelInheritanceSupportInGson(List<?> allModels) {
|
public static List<Map<String, Object>> modelInheritanceSupportInGson(List<?> allModels) {
|
||||||
LinkedListMultimap<CodegenModel, CodegenModel> byParent = LinkedListMultimap.create();
|
Map<CodegenModel, List<CodegenModel>> byParent = new LinkedHashMap<>();
|
||||||
for (Object m : allModels) {
|
for (Object model : allModels) {
|
||||||
Map entry = (Map) m;
|
Map entry = (Map) model;
|
||||||
CodegenModel parent = ((CodegenModel) entry.get("model")).parentModel;
|
CodegenModel parent = ((CodegenModel)entry.get("model")).parentModel;
|
||||||
if (null != parent) {
|
if(null!= parent) {
|
||||||
byParent.put(parent, ((CodegenModel) entry.get("model")));
|
byParent.computeIfAbsent(parent, k -> new LinkedList<>()).add((CodegenModel)entry.get("model"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
List<Map<String, Object>> parentsList = new ArrayList<>();
|
List<Map<String, Object>> parentsList = new ArrayList<>();
|
||||||
|
12
pom.xml
12
pom.xml
@ -77,9 +77,9 @@
|
|||||||
</execution>
|
</execution>
|
||||||
</executions> -->
|
</executions> -->
|
||||||
<configuration>
|
<configuration>
|
||||||
<compilerSource>1.7</compilerSource>
|
<compilerSource>1.8</compilerSource>
|
||||||
<compilerCompliance>1.7</compilerCompliance>
|
<compilerCompliance>1.8</compilerCompliance>
|
||||||
<compilerTargetPlatform>1.7</compilerTargetPlatform>
|
<compilerTargetPlatform>1.8</compilerTargetPlatform>
|
||||||
<lineEnding>LF</lineEnding>
|
<lineEnding>LF</lineEnding>
|
||||||
</configuration>
|
</configuration>
|
||||||
</plugin>
|
</plugin>
|
||||||
@ -153,8 +153,8 @@
|
|||||||
<artifactId>maven-compiler-plugin</artifactId>
|
<artifactId>maven-compiler-plugin</artifactId>
|
||||||
<version>3.6.1</version>
|
<version>3.6.1</version>
|
||||||
<configuration>
|
<configuration>
|
||||||
<source>1.7</source>
|
<source>1.8</source>
|
||||||
<target>1.7</target>
|
<target>1.8</target>
|
||||||
</configuration>
|
</configuration>
|
||||||
</plugin>
|
</plugin>
|
||||||
<plugin>
|
<plugin>
|
||||||
@ -189,7 +189,7 @@
|
|||||||
<version>2.10.4</version>
|
<version>2.10.4</version>
|
||||||
<configuration>
|
<configuration>
|
||||||
<aggregate>true</aggregate>
|
<aggregate>true</aggregate>
|
||||||
<source>1.7</source>
|
<source>1.8</source>
|
||||||
<encoding>UTF-8</encoding>
|
<encoding>UTF-8</encoding>
|
||||||
<maxmemory>1g</maxmemory>
|
<maxmemory>1g</maxmemory>
|
||||||
<excludePackageNames>${javadoc.package.exclude}</excludePackageNames>
|
<excludePackageNames>${javadoc.package.exclude}</excludePackageNames>
|
||||||
|
12
pom.xml.bash
12
pom.xml.bash
@ -83,9 +83,9 @@
|
|||||||
</execution>
|
</execution>
|
||||||
</executions> -->
|
</executions> -->
|
||||||
<configuration>
|
<configuration>
|
||||||
<compilerSource>1.7</compilerSource>
|
<compilerSource>1.8</compilerSource>
|
||||||
<compilerCompliance>1.7</compilerCompliance>
|
<compilerCompliance>1.8</compilerCompliance>
|
||||||
<compilerTargetPlatform>1.7</compilerTargetPlatform>
|
<compilerTargetPlatform>1.8</compilerTargetPlatform>
|
||||||
<lineEnding>LF</lineEnding>
|
<lineEnding>LF</lineEnding>
|
||||||
</configuration>
|
</configuration>
|
||||||
</plugin>
|
</plugin>
|
||||||
@ -159,8 +159,8 @@
|
|||||||
<artifactId>maven-compiler-plugin</artifactId>
|
<artifactId>maven-compiler-plugin</artifactId>
|
||||||
<version>3.6.1</version>
|
<version>3.6.1</version>
|
||||||
<configuration>
|
<configuration>
|
||||||
<source>1.7</source>
|
<source>1.8</source>
|
||||||
<target>1.7</target>
|
<target>1.8</target>
|
||||||
</configuration>
|
</configuration>
|
||||||
</plugin>
|
</plugin>
|
||||||
<plugin>
|
<plugin>
|
||||||
@ -195,7 +195,7 @@
|
|||||||
<version>2.10.4</version>
|
<version>2.10.4</version>
|
||||||
<configuration>
|
<configuration>
|
||||||
<aggregate>true</aggregate>
|
<aggregate>true</aggregate>
|
||||||
<source>1.7</source>
|
<source>1.8</source>
|
||||||
<encoding>UTF-8</encoding>
|
<encoding>UTF-8</encoding>
|
||||||
<maxmemory>1g</maxmemory>
|
<maxmemory>1g</maxmemory>
|
||||||
<excludePackageNames>${javadoc.package.exclude}</excludePackageNames>
|
<excludePackageNames>${javadoc.package.exclude}</excludePackageNames>
|
||||||
|
@ -81,9 +81,9 @@
|
|||||||
</execution>
|
</execution>
|
||||||
</executions> -->
|
</executions> -->
|
||||||
<configuration>
|
<configuration>
|
||||||
<compilerSource>1.7</compilerSource>
|
<compilerSource>1.8</compilerSource>
|
||||||
<compilerCompliance>1.7</compilerCompliance>
|
<compilerCompliance>1.8</compilerCompliance>
|
||||||
<compilerTargetPlatform>1.7</compilerTargetPlatform>
|
<compilerTargetPlatform>1.8</compilerTargetPlatform>
|
||||||
<lineEnding>LF</lineEnding>
|
<lineEnding>LF</lineEnding>
|
||||||
</configuration>
|
</configuration>
|
||||||
</plugin>
|
</plugin>
|
||||||
@ -157,8 +157,8 @@
|
|||||||
<artifactId>maven-compiler-plugin</artifactId>
|
<artifactId>maven-compiler-plugin</artifactId>
|
||||||
<version>3.6.1</version>
|
<version>3.6.1</version>
|
||||||
<configuration>
|
<configuration>
|
||||||
<source>1.7</source>
|
<source>1.8</source>
|
||||||
<target>1.7</target>
|
<target>1.8</target>
|
||||||
</configuration>
|
</configuration>
|
||||||
</plugin>
|
</plugin>
|
||||||
<plugin>
|
<plugin>
|
||||||
@ -193,7 +193,7 @@
|
|||||||
<version>2.10.4</version>
|
<version>2.10.4</version>
|
||||||
<configuration>
|
<configuration>
|
||||||
<aggregate>true</aggregate>
|
<aggregate>true</aggregate>
|
||||||
<source>1.7</source>
|
<source>1.8</source>
|
||||||
<encoding>UTF-8</encoding>
|
<encoding>UTF-8</encoding>
|
||||||
<maxmemory>1g</maxmemory>
|
<maxmemory>1g</maxmemory>
|
||||||
<excludePackageNames>${javadoc.package.exclude}</excludePackageNames>
|
<excludePackageNames>${javadoc.package.exclude}</excludePackageNames>
|
||||||
|
@ -87,9 +87,9 @@
|
|||||||
</execution>
|
</execution>
|
||||||
</executions> -->
|
</executions> -->
|
||||||
<configuration>
|
<configuration>
|
||||||
<compilerSource>1.7</compilerSource>
|
<compilerSource>1.8</compilerSource>
|
||||||
<compilerCompliance>1.7</compilerCompliance>
|
<compilerCompliance>1.8</compilerCompliance>
|
||||||
<compilerTargetPlatform>1.7</compilerTargetPlatform>
|
<compilerTargetPlatform>1.8</compilerTargetPlatform>
|
||||||
<lineEnding>LF</lineEnding>
|
<lineEnding>LF</lineEnding>
|
||||||
</configuration>
|
</configuration>
|
||||||
</plugin>
|
</plugin>
|
||||||
@ -163,8 +163,8 @@
|
|||||||
<artifactId>maven-compiler-plugin</artifactId>
|
<artifactId>maven-compiler-plugin</artifactId>
|
||||||
<version>3.6.1</version>
|
<version>3.6.1</version>
|
||||||
<configuration>
|
<configuration>
|
||||||
<source>1.7</source>
|
<source>1.8</source>
|
||||||
<target>1.7</target>
|
<target>1.8</target>
|
||||||
</configuration>
|
</configuration>
|
||||||
</plugin>
|
</plugin>
|
||||||
<plugin>
|
<plugin>
|
||||||
@ -199,7 +199,7 @@
|
|||||||
<version>2.10.4</version>
|
<version>2.10.4</version>
|
||||||
<configuration>
|
<configuration>
|
||||||
<aggregate>true</aggregate>
|
<aggregate>true</aggregate>
|
||||||
<source>1.7</source>
|
<source>1.8</source>
|
||||||
<encoding>UTF-8</encoding>
|
<encoding>UTF-8</encoding>
|
||||||
<maxmemory>1g</maxmemory>
|
<maxmemory>1g</maxmemory>
|
||||||
<excludePackageNames>${javadoc.package.exclude}</excludePackageNames>
|
<excludePackageNames>${javadoc.package.exclude}</excludePackageNames>
|
||||||
|
12
pom.xml.ios
12
pom.xml.ios
@ -83,9 +83,9 @@
|
|||||||
</execution>
|
</execution>
|
||||||
</executions> -->
|
</executions> -->
|
||||||
<configuration>
|
<configuration>
|
||||||
<compilerSource>1.7</compilerSource>
|
<compilerSource>1.8</compilerSource>
|
||||||
<compilerCompliance>1.7</compilerCompliance>
|
<compilerCompliance>1.8</compilerCompliance>
|
||||||
<compilerTargetPlatform>1.7</compilerTargetPlatform>
|
<compilerTargetPlatform>1.8</compilerTargetPlatform>
|
||||||
<lineEnding>LF</lineEnding>
|
<lineEnding>LF</lineEnding>
|
||||||
</configuration>
|
</configuration>
|
||||||
</plugin>
|
</plugin>
|
||||||
@ -159,8 +159,8 @@
|
|||||||
<artifactId>maven-compiler-plugin</artifactId>
|
<artifactId>maven-compiler-plugin</artifactId>
|
||||||
<version>3.6.1</version>
|
<version>3.6.1</version>
|
||||||
<configuration>
|
<configuration>
|
||||||
<source>1.7</source>
|
<source>1.8</source>
|
||||||
<target>1.7</target>
|
<target>1.8</target>
|
||||||
</configuration>
|
</configuration>
|
||||||
</plugin>
|
</plugin>
|
||||||
<plugin>
|
<plugin>
|
||||||
@ -195,7 +195,7 @@
|
|||||||
<version>2.10.4</version>
|
<version>2.10.4</version>
|
||||||
<configuration>
|
<configuration>
|
||||||
<aggregate>true</aggregate>
|
<aggregate>true</aggregate>
|
||||||
<source>1.7</source>
|
<source>1.8</source>
|
||||||
<encoding>UTF-8</encoding>
|
<encoding>UTF-8</encoding>
|
||||||
<maxmemory>1g</maxmemory>
|
<maxmemory>1g</maxmemory>
|
||||||
<excludePackageNames>${javadoc.package.exclude}</excludePackageNames>
|
<excludePackageNames>${javadoc.package.exclude}</excludePackageNames>
|
||||||
|
@ -77,9 +77,9 @@
|
|||||||
</execution>
|
</execution>
|
||||||
</executions> -->
|
</executions> -->
|
||||||
<configuration>
|
<configuration>
|
||||||
<compilerSource>1.7</compilerSource>
|
<compilerSource>1.8</compilerSource>
|
||||||
<compilerCompliance>1.7</compilerCompliance>
|
<compilerCompliance>1.8</compilerCompliance>
|
||||||
<compilerTargetPlatform>1.7</compilerTargetPlatform>
|
<compilerTargetPlatform>1.8</compilerTargetPlatform>
|
||||||
<lineEnding>LF</lineEnding>
|
<lineEnding>LF</lineEnding>
|
||||||
</configuration>
|
</configuration>
|
||||||
</plugin>
|
</plugin>
|
||||||
@ -153,8 +153,8 @@
|
|||||||
<artifactId>maven-compiler-plugin</artifactId>
|
<artifactId>maven-compiler-plugin</artifactId>
|
||||||
<version>3.6.1</version>
|
<version>3.6.1</version>
|
||||||
<configuration>
|
<configuration>
|
||||||
<source>1.7</source>
|
<source>1.8</source>
|
||||||
<target>1.7</target>
|
<target>1.8</target>
|
||||||
</configuration>
|
</configuration>
|
||||||
</plugin>
|
</plugin>
|
||||||
<plugin>
|
<plugin>
|
||||||
@ -189,7 +189,7 @@
|
|||||||
<version>2.10.4</version>
|
<version>2.10.4</version>
|
||||||
<configuration>
|
<configuration>
|
||||||
<aggregate>true</aggregate>
|
<aggregate>true</aggregate>
|
||||||
<source>1.7</source>
|
<source>1.8</source>
|
||||||
<encoding>UTF-8</encoding>
|
<encoding>UTF-8</encoding>
|
||||||
<maxmemory>1g</maxmemory>
|
<maxmemory>1g</maxmemory>
|
||||||
<excludePackageNames>${javadoc.package.exclude}</excludePackageNames>
|
<excludePackageNames>${javadoc.package.exclude}</excludePackageNames>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user