forked from loafle/openapi-generator-original
moved templates files and use only one engine (handlebars)
This commit is contained in:
@@ -31,8 +31,6 @@ public class Generate implements Runnable {
|
||||
private String output = "";
|
||||
private String spec;
|
||||
private String templateDir;
|
||||
private String templateEngine;
|
||||
private String templateFileExtension;
|
||||
private String auth;
|
||||
private List<String> systemProperties = new ArrayList<>();
|
||||
private String configFile;
|
||||
@@ -79,14 +77,6 @@ public class Generate implements Runnable {
|
||||
this.templateDir = templateDir;
|
||||
}
|
||||
|
||||
public void setTemplateEngine(String templateEngine) {
|
||||
this.templateEngine = templateEngine;
|
||||
}
|
||||
|
||||
public void setTemplateFileExtension(String templateFileExtension) {
|
||||
this.templateFileExtension = templateFileExtension;
|
||||
}
|
||||
|
||||
public void setAuth(String auth) {
|
||||
this.auth = auth;
|
||||
}
|
||||
@@ -228,14 +218,6 @@ public class Generate implements Runnable {
|
||||
configurator.setTemplateDir(templateDir);
|
||||
}
|
||||
|
||||
if (isNotEmpty(templateEngine)) {
|
||||
configurator.setTemplateEngine(templateEngine);
|
||||
}
|
||||
|
||||
if (isNotEmpty(templateFileExtension)) {
|
||||
configurator.setTemplateFileExtension(templateFileExtension);
|
||||
}
|
||||
|
||||
if (isNotEmpty(apiPackage)) {
|
||||
configurator.setApiPackage(apiPackage);
|
||||
}
|
||||
|
||||
@@ -173,19 +173,6 @@ components:
|
||||
title: "remove prefix of the operationId"
|
||||
description: "Remove prefix of operationId, e.g. config_getId => getId"
|
||||
x-option: "--remove-operation-id-prefix"
|
||||
templateEngine:
|
||||
type: "string"
|
||||
title: "template engine"
|
||||
description: "template engine to generate files. (default is 'mustache'"
|
||||
example: "mustache, handlebars"
|
||||
x-option: "--template-engine"
|
||||
x-short-version: "-e"
|
||||
templateFileExtension:
|
||||
type: "string"
|
||||
title: "template file extension"
|
||||
description: "extension related to template files."
|
||||
example: ".mustache, .hbs"
|
||||
x-option: "--template-file-extension"
|
||||
ConfigHelp:
|
||||
x-command: "config-help"
|
||||
x-command-description: "Config help for chosen lang"
|
||||
|
||||
@@ -39,12 +39,6 @@ public interface CodegenConfig {
|
||||
|
||||
String templateDir();
|
||||
|
||||
String templateEngine();
|
||||
|
||||
String templateFileExtension();
|
||||
|
||||
String resolveExtension();
|
||||
|
||||
String embeddedTemplateDir();
|
||||
|
||||
String modelFileFolder();
|
||||
|
||||
@@ -22,8 +22,6 @@ public class CodegenConstants {
|
||||
public static final String MODEL_PACKAGE_DESC = "package for generated models";
|
||||
|
||||
public static final String TEMPLATE_DIR = "templateDir";
|
||||
public static final String TEMPLATE_ENGINE = "templateEngine";
|
||||
public static final String TEMPLATE_FILE_EXTENSION = "templateDir";
|
||||
|
||||
public static final String ALLOW_UNICODE_IDENTIFIERS = "allowUnicodeIdentifiers";
|
||||
public static final String ALLOW_UNICODE_IDENTIFIERS_DESC = "boolean, toggles whether unicode identifiers are allowed in names or not, default is false";
|
||||
|
||||
@@ -83,11 +83,6 @@ public class DefaultCodegen implements CodegenConfig {
|
||||
protected static final Logger LOGGER = LoggerFactory.getLogger(DefaultCodegen.class);
|
||||
public static final String DEFAULT_CONTENT_TYPE = "application/json";
|
||||
|
||||
public static final String MUSTACHE_TEMPLATE = "mustache";
|
||||
public static final String MUSTACHE_EXTENSION = ".mustache";
|
||||
public static final String HANDLEBARS_TEMPLATE = "handlebars";
|
||||
public static final String HANDLEBARS_EXTENSION = ".hbs";
|
||||
|
||||
protected String inputSpec;
|
||||
protected String outputFolder = "";
|
||||
protected Set<String> defaultIncludes = new HashSet<String>();
|
||||
@@ -107,8 +102,6 @@ public class DefaultCodegen implements CodegenConfig {
|
||||
protected Map<String, String> modelDocTemplateFiles = new HashMap<String, String>();
|
||||
protected Map<String, String> reservedWordsMappings = new HashMap<String, String>();
|
||||
protected String templateDir;
|
||||
protected String templateEngine;
|
||||
protected String templateFileExtension;
|
||||
protected String embeddedTemplateDir;
|
||||
protected String commonTemplateDir = "_common";
|
||||
protected Map<String, Object> additionalProperties = new HashMap<String, Object>();
|
||||
@@ -145,14 +138,6 @@ public class DefaultCodegen implements CodegenConfig {
|
||||
this.setTemplateDir((String) additionalProperties.get(CodegenConstants.TEMPLATE_DIR));
|
||||
}
|
||||
|
||||
if (additionalProperties.containsKey(CodegenConstants.TEMPLATE_FILE_EXTENSION)) {
|
||||
this.setTemplateFileExtension((String) additionalProperties.get(CodegenConstants.TEMPLATE_FILE_EXTENSION));
|
||||
}
|
||||
|
||||
if (additionalProperties.containsKey(CodegenConstants.TEMPLATE_ENGINE)) {
|
||||
this.setTemplateEngine((String) additionalProperties.get(CodegenConstants.TEMPLATE_ENGINE));
|
||||
}
|
||||
|
||||
if (additionalProperties.containsKey(CodegenConstants.MODEL_PACKAGE)) {
|
||||
this.setModelPackage((String) additionalProperties.get(CodegenConstants.MODEL_PACKAGE));
|
||||
}
|
||||
@@ -407,26 +392,6 @@ public class DefaultCodegen implements CodegenConfig {
|
||||
}
|
||||
}
|
||||
|
||||
public String templateEngine() {
|
||||
return templateEngine;
|
||||
}
|
||||
|
||||
public String templateFileExtension() {
|
||||
return templateFileExtension;
|
||||
}
|
||||
|
||||
public String resolveExtension() {
|
||||
String extension = DefaultCodegen.MUSTACHE_EXTENSION;
|
||||
if (DefaultCodegen.HANDLEBARS_TEMPLATE.equals(this.templateEngine())) {
|
||||
if (StringUtils.isNotBlank(this.templateFileExtension())) {
|
||||
extension = this.templateFileExtension();
|
||||
} else {
|
||||
extension = DefaultCodegen.HANDLEBARS_EXTENSION;
|
||||
}
|
||||
}
|
||||
return extension;
|
||||
}
|
||||
|
||||
public String getCommonTemplateDir() {
|
||||
return this.commonTemplateDir;
|
||||
}
|
||||
@@ -523,14 +488,6 @@ public class DefaultCodegen implements CodegenConfig {
|
||||
this.templateDir = templateDir;
|
||||
}
|
||||
|
||||
public void setTemplateEngine(String templateEngine) {
|
||||
this.templateEngine = templateEngine;
|
||||
}
|
||||
|
||||
public void setTemplateFileExtension(String templateFileExtension) {
|
||||
this.templateFileExtension = templateFileExtension;
|
||||
}
|
||||
|
||||
public void setModelPackage(String modelPackage) {
|
||||
this.modelPackage = modelPackage;
|
||||
}
|
||||
|
||||
@@ -574,27 +574,10 @@ public class DefaultGenerator extends AbstractGenerator implements Generator {
|
||||
}
|
||||
|
||||
if(ignoreProcessor.allowsFile(new File(outputFilename))) {
|
||||
if (templateFile.endsWith("mustache") || templateFile.endsWith("hbs")) {
|
||||
String template = readTemplate(templateFile);
|
||||
String rendered = null;
|
||||
if (DefaultCodegen.HANDLEBARS_TEMPLATE.equals(config.templateEngine())) {
|
||||
String templateName = templateFile.replace("\\", "/");
|
||||
final com.github.jknack.handlebars.Template hTemplate = getHandlebars(templateName.replace(config.templateDir(), StringUtils.EMPTY));
|
||||
rendered = hTemplate.apply(bundle);
|
||||
} else {
|
||||
Mustache.Compiler compiler = Mustache.compiler();
|
||||
compiler = config.processCompiler(compiler);
|
||||
Template tmpl = compiler
|
||||
.withLoader(new Mustache.TemplateLoader() {
|
||||
@Override
|
||||
public Reader getTemplate(String name) {
|
||||
return getTemplateReader(getFullTemplateFile(config, name + ".mustache"));
|
||||
}
|
||||
})
|
||||
.defaultValue("")
|
||||
.compile(template);
|
||||
rendered = tmpl.execute(bundle);
|
||||
}
|
||||
if (templateFile.endsWith("mustache")) {
|
||||
String templateName = templateFile.replace("\\", "/");
|
||||
final com.github.jknack.handlebars.Template hTemplate = getHandlebars(templateName.replace(config.templateDir(), StringUtils.EMPTY));
|
||||
String rendered = hTemplate.apply(bundle);
|
||||
writeToFile(outputFilename, rendered);
|
||||
|
||||
// writeToFile(outputFilename, tmpl.execute(bundle));
|
||||
@@ -751,26 +734,8 @@ public class DefaultGenerator extends AbstractGenerator implements Generator {
|
||||
String adjustedOutputFilename = outputFilename.replaceAll("//", "/").replace('/', File.separatorChar);
|
||||
if(ignoreProcessor.allowsFile(new File(adjustedOutputFilename))) {
|
||||
String templateFile = getFullTemplateFile(config, templateName);
|
||||
String template = readTemplate(templateFile);
|
||||
|
||||
String rendered = null;
|
||||
if (DefaultCodegen.HANDLEBARS_TEMPLATE.equals(config.templateEngine())) {
|
||||
final com.github.jknack.handlebars.Template hTemplate = getHandlebars(templateFile);
|
||||
rendered = hTemplate.apply(templateData);
|
||||
} else {
|
||||
Mustache.Compiler compiler = Mustache.compiler();
|
||||
compiler = config.processCompiler(compiler);
|
||||
Template tmpl = compiler
|
||||
.withLoader(new Mustache.TemplateLoader() {
|
||||
@Override
|
||||
public Reader getTemplate(String name) {
|
||||
return getTemplateReader(getFullTemplateFile(config, name + config.resolveExtension()));
|
||||
}
|
||||
})
|
||||
.defaultValue("")
|
||||
.compile(template);
|
||||
rendered = tmpl.execute(templateData);
|
||||
}
|
||||
final com.github.jknack.handlebars.Template hTemplate = getHandlebars(templateFile);
|
||||
String rendered = hTemplate.apply(templateData);
|
||||
writeToFile(adjustedOutputFilename, rendered);
|
||||
return new File(adjustedOutputFilename);
|
||||
}
|
||||
@@ -1040,10 +1005,10 @@ public class DefaultGenerator extends AbstractGenerator implements Generator {
|
||||
if (templateFile.startsWith(config.templateDir())) {
|
||||
templateFile = templateFile.replaceFirst(config.templateDir(), StringUtils.EMPTY);
|
||||
}
|
||||
final TemplateLoader templateLoader = new ClassPathTemplateLoader("/" + config.templateDir(), config.resolveExtension());
|
||||
final TemplateLoader templateLoader = new ClassPathTemplateLoader("/" + config.templateDir(), ".mustache");
|
||||
final Handlebars handlebars = new Handlebars(templateLoader);
|
||||
config.addHandlebarHelpers(handlebars);
|
||||
|
||||
return handlebars.compile(templateFile.replace(config.resolveExtension(), StringUtils.EMPTY));
|
||||
return handlebars.compile(templateFile.replace(".mustache", StringUtils.EMPTY));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -47,8 +47,6 @@ public class CodegenConfigurator implements Serializable {
|
||||
private boolean skipOverwrite;
|
||||
private boolean removeOperationIdPrefix;
|
||||
private String templateDir;
|
||||
private String templateEngine;
|
||||
private String templateFileExtension;
|
||||
private String auth;
|
||||
private String apiPackage;
|
||||
private String modelPackage;
|
||||
@@ -176,24 +174,6 @@ public class CodegenConfigurator implements Serializable {
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getTemplateEngine() {
|
||||
return templateEngine;
|
||||
}
|
||||
|
||||
public CodegenConfigurator setTemplateEngine(String templateEngine) {
|
||||
this.templateEngine = templateEngine;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getTemplateFileExtension() {
|
||||
return templateFileExtension;
|
||||
}
|
||||
|
||||
public CodegenConfigurator setTemplateFileExtension(String templateFileExtension) {
|
||||
this.templateFileExtension = templateFileExtension;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getAuth() {
|
||||
return auth;
|
||||
}
|
||||
@@ -429,8 +409,6 @@ public class CodegenConfigurator implements Serializable {
|
||||
checkAndSetAdditionalProperty(artifactId, CodegenConstants.ARTIFACT_ID);
|
||||
checkAndSetAdditionalProperty(artifactVersion, CodegenConstants.ARTIFACT_VERSION);
|
||||
checkAndSetAdditionalProperty(templateDir, toAbsolutePathStr(templateDir), CodegenConstants.TEMPLATE_DIR);
|
||||
checkAndSetAdditionalProperty(templateEngine, CodegenConstants.TEMPLATE_ENGINE);
|
||||
checkAndSetAdditionalProperty(templateFileExtension, CodegenConstants.TEMPLATE_FILE_EXTENSION);
|
||||
checkAndSetAdditionalProperty(modelNamePrefix, CodegenConstants.MODEL_NAME_PREFIX);
|
||||
checkAndSetAdditionalProperty(modelNameSuffix, CodegenConstants.MODEL_NAME_SUFFIX);
|
||||
checkAndSetAdditionalProperty(gitUserId, CodegenConstants.GIT_USER_ID);
|
||||
|
||||
@@ -179,12 +179,11 @@ public abstract class AbstractJavaCodegen extends DefaultCodegen implements Code
|
||||
public void processOpts() {
|
||||
super.processOpts();
|
||||
|
||||
final String extension = resolveExtension();
|
||||
modelTemplateFiles.put(String.format("model%s", extension), ".java");
|
||||
apiTemplateFiles.put(String.format("api%s", extension), ".java");
|
||||
apiTestTemplateFiles.put(String.format("api_test%s", extension), ".java");
|
||||
modelDocTemplateFiles.put(String.format("model_doc%s", extension), ".md");
|
||||
apiDocTemplateFiles.put(String.format("api_doc%s", extension), ".md");
|
||||
modelTemplateFiles.put("model.mustache", ".java");
|
||||
apiTemplateFiles.put("api.mustache", ".java");
|
||||
apiTestTemplateFiles.put("api_test.mustache", ".java");
|
||||
modelDocTemplateFiles.put("model_doc.mustache", ".md");
|
||||
apiDocTemplateFiles.put("api_doc.mustache", ".md");
|
||||
|
||||
if (additionalProperties.containsKey(SUPPORT_JAVA6)) {
|
||||
this.setSupportJava6(Boolean.valueOf(additionalProperties.get(SUPPORT_JAVA6).toString()));
|
||||
|
||||
@@ -114,10 +114,7 @@ public class JavaClientCodegen extends AbstractJavaCodegen
|
||||
@Override
|
||||
public void processOpts() {
|
||||
super.processOpts();
|
||||
|
||||
if (HANDLEBARS_TEMPLATE.equals(templateEngine)) {
|
||||
embeddedTemplateDir = templateDir = "handlebars/v1/Java";
|
||||
}
|
||||
embeddedTemplateDir = templateDir = "v2/Java";
|
||||
|
||||
if (additionalProperties.containsKey(USE_RX_JAVA) && additionalProperties.containsKey(USE_RX_JAVA2)) {
|
||||
LOGGER.warn("You specified both RxJava versions 1 and 2 but they are mutually exclusive. Defaulting to v2.");
|
||||
@@ -166,84 +163,82 @@ public class JavaClientCodegen extends AbstractJavaCodegen
|
||||
final String authFolder = (sourceFolder + '/' + invokerPackage + ".auth").replace(".", "/");
|
||||
final String apiFolder = (sourceFolder + '/' + apiPackage).replace(".", "/");
|
||||
|
||||
String extension = this.resolveExtension();
|
||||
|
||||
//Common files
|
||||
writeOptional(outputFolder, new SupportingFile("pom" + extension, "", "pom.xml"));
|
||||
writeOptional(outputFolder, new SupportingFile("README" + extension, "", "README.md"));
|
||||
writeOptional(outputFolder, new SupportingFile("build.gradle" + extension, "", "build.gradle"));
|
||||
writeOptional(outputFolder, new SupportingFile("build.sbt" + extension, "", "build.sbt"));
|
||||
writeOptional(outputFolder, new SupportingFile("settings.gradle" + extension, "", "settings.gradle"));
|
||||
writeOptional(outputFolder, new SupportingFile("gradle.properties" + extension, "", "gradle.properties"));
|
||||
writeOptional(outputFolder, new SupportingFile("manifest" + extension, projectFolder, "AndroidManifest.xml"));
|
||||
supportingFiles.add(new SupportingFile("travis" + extension, "", ".travis.yml"));
|
||||
supportingFiles.add(new SupportingFile("ApiClient" + extension, invokerFolder, "ApiClient.java"));
|
||||
writeOptional(outputFolder, new SupportingFile("pom.mustache", "", "pom.xml"));
|
||||
writeOptional(outputFolder, new SupportingFile("README.mustache", "", "README.md"));
|
||||
writeOptional(outputFolder, new SupportingFile("build.gradle.mustache", "", "build.gradle"));
|
||||
writeOptional(outputFolder, new SupportingFile("build.sbt.mustache", "", "build.sbt"));
|
||||
writeOptional(outputFolder, new SupportingFile("settings.gradle.mustache", "", "settings.gradle"));
|
||||
writeOptional(outputFolder, new SupportingFile("gradle.properties.mustache", "", "gradle.properties"));
|
||||
writeOptional(outputFolder, new SupportingFile("manifest.mustache", projectFolder, "AndroidManifest.xml"));
|
||||
supportingFiles.add(new SupportingFile("travis.mustache", "", ".travis.yml"));
|
||||
supportingFiles.add(new SupportingFile("ApiClient.mustache", invokerFolder, "ApiClient.java"));
|
||||
if(!"resttemplate".equals(getLibrary())) {
|
||||
supportingFiles.add(new SupportingFile("StringUtil" + extension, invokerFolder, "StringUtil.java"));
|
||||
supportingFiles.add(new SupportingFile("StringUtil.mustache", invokerFolder, "StringUtil.java"));
|
||||
}
|
||||
|
||||
// google-api-client doesn't use the Swagger auth, because it uses Google Credential directly (HttpRequestInitializer)
|
||||
if (!"google-api-client".equals(getLibrary())) {
|
||||
supportingFiles.add(new SupportingFile("auth/HttpBasicAuth" + extension, authFolder, "HttpBasicAuth.java"));
|
||||
supportingFiles.add(new SupportingFile("auth/ApiKeyAuth" + extension, authFolder, "ApiKeyAuth.java"));
|
||||
supportingFiles.add(new SupportingFile("auth/OAuth" + extension, authFolder, "OAuth.java"));
|
||||
supportingFiles.add(new SupportingFile("auth/OAuthFlow" + extension, authFolder, "OAuthFlow.java"));
|
||||
supportingFiles.add(new SupportingFile("auth/HttpBasicAuth.mustache", authFolder, "HttpBasicAuth.java"));
|
||||
supportingFiles.add(new SupportingFile("auth/ApiKeyAuth.mustache", authFolder, "ApiKeyAuth.java"));
|
||||
supportingFiles.add(new SupportingFile("auth/OAuth.mustache", authFolder, "OAuth.java"));
|
||||
supportingFiles.add(new SupportingFile("auth/OAuthFlow.mustache", authFolder, "OAuthFlow.java"));
|
||||
}
|
||||
supportingFiles.add(new SupportingFile( "gradlew" + extension, "", "gradlew") );
|
||||
supportingFiles.add(new SupportingFile( "gradlew.bat" + extension, "", "gradlew.bat") );
|
||||
supportingFiles.add(new SupportingFile( "gradle-wrapper.properties" + extension,
|
||||
supportingFiles.add(new SupportingFile( "gradlew.mustache", "", "gradlew") );
|
||||
supportingFiles.add(new SupportingFile( "gradlew.bat.mustache", "", "gradlew.bat") );
|
||||
supportingFiles.add(new SupportingFile( "gradle-wrapper.properties.mustache",
|
||||
gradleWrapperPackage.replace( ".", File.separator ), "gradle-wrapper.properties") );
|
||||
supportingFiles.add(new SupportingFile( "gradle-wrapper.jar",
|
||||
gradleWrapperPackage.replace( ".", File.separator ), "gradle-wrapper.jar") );
|
||||
supportingFiles.add(new SupportingFile("git_push.sh\" + extension", "", "git_push.sh"));
|
||||
supportingFiles.add(new SupportingFile("gitignore" + extension, "", ".gitignore"));
|
||||
supportingFiles.add(new SupportingFile("git_push.sh.mustache", "", "git_push.sh"));
|
||||
supportingFiles.add(new SupportingFile("gitignore.mustache", "", ".gitignore"));
|
||||
|
||||
if (performBeanValidation) {
|
||||
supportingFiles.add(new SupportingFile("BeanValidationException" + extension, invokerFolder,
|
||||
supportingFiles.add(new SupportingFile("BeanValidationException.mustache", invokerFolder,
|
||||
"BeanValidationException.java"));
|
||||
}
|
||||
|
||||
//TODO: add doc to retrofit1 and feign
|
||||
if ( "feign".equals(getLibrary()) || "retrofit".equals(getLibrary()) ){
|
||||
modelDocTemplateFiles.remove("model_doc" + extension);
|
||||
apiDocTemplateFiles.remove("api_doc" + extension);
|
||||
modelDocTemplateFiles.remove("model_doc.mustache");
|
||||
apiDocTemplateFiles.remove("api_doc.mustache");
|
||||
}
|
||||
|
||||
if (!("feign".equals(getLibrary()) || "resttemplate".equals(getLibrary()) || usesAnyRetrofitLibrary() || "google-api-client".equals(getLibrary()))) {
|
||||
supportingFiles.add(new SupportingFile("apiException" + extension, invokerFolder, "ApiException.java"));
|
||||
supportingFiles.add(new SupportingFile("Configuration" + extension, invokerFolder, "Configuration.java"));
|
||||
supportingFiles.add(new SupportingFile("Pair" + extension, invokerFolder, "Pair.java"));
|
||||
supportingFiles.add(new SupportingFile("auth/Authentication" + extension, authFolder, "Authentication.java"));
|
||||
supportingFiles.add(new SupportingFile("apiException.mustache", invokerFolder, "ApiException.java"));
|
||||
supportingFiles.add(new SupportingFile("Configuration.mustache", invokerFolder, "Configuration.java"));
|
||||
supportingFiles.add(new SupportingFile("Pair.mustache", invokerFolder, "Pair.java"));
|
||||
supportingFiles.add(new SupportingFile("auth/Authentication.mustache", authFolder, "Authentication.java"));
|
||||
}
|
||||
|
||||
if ("feign".equals(getLibrary())) {
|
||||
additionalProperties.put("jackson", "true");
|
||||
supportingFiles.add(new SupportingFile("ParamExpander" + extension, invokerFolder, "ParamExpander.java"));
|
||||
supportingFiles.add(new SupportingFile("EncodingUtils" + extension, invokerFolder, "EncodingUtils.java"));
|
||||
supportingFiles.add(new SupportingFile("ParamExpander.mustache", invokerFolder, "ParamExpander.java"));
|
||||
supportingFiles.add(new SupportingFile("EncodingUtils.mustache", invokerFolder, "EncodingUtils.java"));
|
||||
} else if ("okhttp-gson".equals(getLibrary()) || StringUtils.isEmpty(getLibrary())) {
|
||||
// the "okhttp-gson" library template requires "ApiCallback.mustache" for async call
|
||||
supportingFiles.add(new SupportingFile("ApiCallback" + extension, invokerFolder, "ApiCallback.java"));
|
||||
supportingFiles.add(new SupportingFile("ApiResponse" + extension, invokerFolder, "ApiResponse.java"));
|
||||
supportingFiles.add(new SupportingFile("JSON" + extension, invokerFolder, "JSON.java"));
|
||||
supportingFiles.add(new SupportingFile("ProgressRequestBody" + extension, invokerFolder, "ProgressRequestBody.java"));
|
||||
supportingFiles.add(new SupportingFile("ProgressResponseBody" + extension, invokerFolder, "ProgressResponseBody.java"));
|
||||
supportingFiles.add(new SupportingFile("GzipRequestInterceptor" + extension, invokerFolder, "GzipRequestInterceptor.java"));
|
||||
supportingFiles.add(new SupportingFile("ApiCallback.mustache", invokerFolder, "ApiCallback.java"));
|
||||
supportingFiles.add(new SupportingFile("ApiResponse.mustache", invokerFolder, "ApiResponse.java"));
|
||||
supportingFiles.add(new SupportingFile("JSON.mustache", invokerFolder, "JSON.java"));
|
||||
supportingFiles.add(new SupportingFile("ProgressRequestBody.mustache", invokerFolder, "ProgressRequestBody.java"));
|
||||
supportingFiles.add(new SupportingFile("ProgressResponseBody.mustache", invokerFolder, "ProgressResponseBody.java"));
|
||||
supportingFiles.add(new SupportingFile("GzipRequestInterceptor.mustache", invokerFolder, "GzipRequestInterceptor.java"));
|
||||
additionalProperties.put("gson", "true");
|
||||
} else if (usesAnyRetrofitLibrary()) {
|
||||
supportingFiles.add(new SupportingFile("auth/OAuthOkHttpClient" + extension, authFolder, "OAuthOkHttpClient.java"));
|
||||
supportingFiles.add(new SupportingFile("CollectionFormats" + extension, invokerFolder, "CollectionFormats.java"));
|
||||
supportingFiles.add(new SupportingFile("auth/OAuthOkHttpClient.mustache", authFolder, "OAuthOkHttpClient.java"));
|
||||
supportingFiles.add(new SupportingFile("CollectionFormats.mustache", invokerFolder, "CollectionFormats.java"));
|
||||
additionalProperties.put("gson", "true");
|
||||
if ("retrofit2".equals(getLibrary()) && !usePlayWS) {
|
||||
supportingFiles.add(new SupportingFile("JSON" + extension, invokerFolder, "JSON.java"));
|
||||
supportingFiles.add(new SupportingFile("JSON.mustache", invokerFolder, "JSON.java"));
|
||||
}
|
||||
} else if ("jersey2".equals(getLibrary()) || "resteasy".equals(getLibrary())) {
|
||||
supportingFiles.add(new SupportingFile("JSON" + extension, invokerFolder, "JSON.java"));
|
||||
supportingFiles.add(new SupportingFile("JSON.mustache", invokerFolder, "JSON.java"));
|
||||
additionalProperties.put("jackson", "true");
|
||||
} else if("jersey1".equals(getLibrary())) {
|
||||
additionalProperties.put("jackson", "true");
|
||||
} else if("resttemplate".equals(getLibrary())) {
|
||||
additionalProperties.put("jackson", "true");
|
||||
supportingFiles.add(new SupportingFile("auth/Authentication" + extension, authFolder, "Authentication.java"));
|
||||
supportingFiles.add(new SupportingFile("auth/Authentication.mustache", authFolder, "Authentication.java"));
|
||||
} else if("vertx".equals(getLibrary())) {
|
||||
typeMapping.put("file", "AsyncFile");
|
||||
importMapping.put("AsyncFile", "io.vertx.core.file.AsyncFile");
|
||||
@@ -251,9 +246,9 @@ public class JavaClientCodegen extends AbstractJavaCodegen
|
||||
additionalProperties.put("java8", "true");
|
||||
additionalProperties.put("jackson", "true");
|
||||
|
||||
apiTemplateFiles.put("apiImpl" + extension, "Impl.java");
|
||||
apiTemplateFiles.put("rxApiImpl" + extension, ".java");
|
||||
supportingFiles.remove(new SupportingFile("manifest" + extension, projectFolder, "AndroidManifest.xml"));
|
||||
apiTemplateFiles.put("apiImpl.mustache", "Impl.java");
|
||||
apiTemplateFiles.put("rxApiImpl.mustache", ".java");
|
||||
supportingFiles.remove(new SupportingFile("manifest.mustache", projectFolder, "AndroidManifest.xml"));
|
||||
} else if ("google-api-client".equals(getLibrary())) {
|
||||
additionalProperties.put("jackson", "true");
|
||||
} else {
|
||||
@@ -270,39 +265,39 @@ public class JavaClientCodegen extends AbstractJavaCodegen
|
||||
}
|
||||
}
|
||||
|
||||
apiTemplateFiles.remove("api" + extension);
|
||||
apiTemplateFiles.remove("api.mustache");
|
||||
|
||||
if (PLAY_24.equals(playVersion)) {
|
||||
additionalProperties.put(PLAY_24, true);
|
||||
apiTemplateFiles.put("play24/api" + extension, ".java");
|
||||
apiTemplateFiles.put("play24/api.mustache", ".java");
|
||||
|
||||
supportingFiles.add(new SupportingFile("play24/ApiClient" + extension, invokerFolder, "ApiClient.java"));
|
||||
supportingFiles.add(new SupportingFile("play24/Play24CallFactory" + extension, invokerFolder, "Play24CallFactory.java"));
|
||||
supportingFiles.add(new SupportingFile("play24/Play24CallAdapterFactory" + extension, invokerFolder,
|
||||
supportingFiles.add(new SupportingFile("play24/ApiClient.mustache", invokerFolder, "ApiClient.java"));
|
||||
supportingFiles.add(new SupportingFile("play24/Play24CallFactory.mustache", invokerFolder, "Play24CallFactory.java"));
|
||||
supportingFiles.add(new SupportingFile("play24/Play24CallAdapterFactory.mustache", invokerFolder,
|
||||
"Play24CallAdapterFactory.java"));
|
||||
} else {
|
||||
additionalProperties.put(PLAY_25, true);
|
||||
apiTemplateFiles.put("play25/api" + extension, ".java");
|
||||
apiTemplateFiles.put("play25/api.mustache", ".java");
|
||||
|
||||
supportingFiles.add(new SupportingFile("play25/ApiClient" + extension, invokerFolder, "ApiClient.java"));
|
||||
supportingFiles.add(new SupportingFile("play25/Play25CallFactory" + extension, invokerFolder, "Play25CallFactory.java"));
|
||||
supportingFiles.add(new SupportingFile("play25/Play25CallAdapterFactory" + extension, invokerFolder,
|
||||
supportingFiles.add(new SupportingFile("play25/ApiClient.mustache", invokerFolder, "ApiClient.java"));
|
||||
supportingFiles.add(new SupportingFile("play25/Play25CallFactory.mustache", invokerFolder, "Play25CallFactory.java"));
|
||||
supportingFiles.add(new SupportingFile("play25/Play25CallAdapterFactory.mustache", invokerFolder,
|
||||
"Play25CallAdapterFactory.java"));
|
||||
additionalProperties.put("java8", "true");
|
||||
}
|
||||
|
||||
supportingFiles.add(new SupportingFile("play-common/auth/ApiKeyAuth" + extension, authFolder, "ApiKeyAuth.java"));
|
||||
supportingFiles.add(new SupportingFile("auth/Authentication" + extension, authFolder, "Authentication.java"));
|
||||
supportingFiles.add(new SupportingFile("Pair" + extension, invokerFolder, "Pair.java"));
|
||||
supportingFiles.add(new SupportingFile("play-common/auth/ApiKeyAuth.mustache", authFolder, "ApiKeyAuth.java"));
|
||||
supportingFiles.add(new SupportingFile("auth/Authentication.mustache", authFolder, "Authentication.java"));
|
||||
supportingFiles.add(new SupportingFile("Pair.mustache", invokerFolder, "Pair.java"));
|
||||
|
||||
additionalProperties.put("jackson", "true");
|
||||
additionalProperties.remove("gson");
|
||||
}
|
||||
|
||||
if (additionalProperties.containsKey("jackson")) {
|
||||
supportingFiles.add(new SupportingFile("RFC3339DateFormat" + extension, invokerFolder, "RFC3339DateFormat.java"));
|
||||
supportingFiles.add(new SupportingFile("RFC3339DateFormat.mustache", invokerFolder, "RFC3339DateFormat.java"));
|
||||
if ("threetenbp".equals(dateLibrary) && !usePlayWS) {
|
||||
supportingFiles.add(new SupportingFile("CustomInstantDeserializer" + extension, invokerFolder, "CustomInstantDeserializer.java"));
|
||||
supportingFiles.add(new SupportingFile("CustomInstantDeserializer.mustache", invokerFolder, "CustomInstantDeserializer.java"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user