Skip to content

Commit 202de30

Browse files
authored
Merge pull request #484 from swagger-api/no_used_templates_removing
No used templates removing
2 parents d09c70e + 72955cf commit 202de30

File tree

15 files changed

+8
-1524
lines changed

15 files changed

+8
-1524
lines changed

src/main/java/io/swagger/codegen/v3/generators/java/JavaClientCodegen.java

Lines changed: 8 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -89,10 +89,8 @@ public JavaClientCodegen() {
8989
supportedLibraries.put("okhttp-gson", "HTTP client: OkHttp 2.7.5. JSON processing: Gson 2.8.1. Enable Parcelable models on Android using '-DparcelableModel=true'. Enable gzip request encoding using '-DuseGzipFeature=true'.");
9090
supportedLibraries.put(RETROFIT_1, "HTTP client: OkHttp 2.7.5. JSON processing: Gson 2.3.1 (Retrofit 1.9.0). IMPORTANT NOTE: retrofit1.x is no longer actively maintained so please upgrade to 'retrofit2' instead.");
9191
supportedLibraries.put(RETROFIT_2, "HTTP client: OkHttp 3.8.0. JSON processing: Gson 2.6.1 (Retrofit 2.3.0). Enable the RxJava adapter using '-DuseRxJava[2]=true'. (RxJava 1.x or 2.x)");
92-
supportedLibraries.put("resttemplate", "HTTP client: Spring RestTemplate 4.3.9-RELEASE. JSON processing: Jackson 2.9.10");
93-
supportedLibraries.put("resteasy", "HTTP client: Resteasy client 3.1.3.Final. JSON processing: Jackson 2.9.10");
94-
supportedLibraries.put("vertx", "HTTP client: VertX client 3.2.4. JSON processing: Jackson 2.9.10");
95-
supportedLibraries.put("google-api-client", "HTTP client: Google API client 1.23.0. JSON processing: Jackson 2.9.10");
92+
supportedLibraries.put("resttemplate", "HTTP client: Spring RestTemplate 4.3.9-RELEASE. JSON processing: Jackson 2.9.9");
93+
supportedLibraries.put("resteasy", "HTTP client: Resteasy client 3.1.3.Final. JSON processing: Jackson 2.9.9");
9694

9795
CliOption libraryOption = new CliOption(CodegenConstants.LIBRARY, "library template (sub-template) to use");
9896
libraryOption.setEnum(supportedLibraries);
@@ -187,14 +185,11 @@ public void processOpts() {
187185
supportingFiles.add(new SupportingFile("StringUtil.mustache", invokerFolder, "StringUtil.java"));
188186
}
189187

190-
// google-api-client doesn't use the Swagger auth, because it uses Google Credential directly (HttpRequestInitializer)
191-
if (!"google-api-client".equals(getLibrary())) {
188+
supportingFiles.add(new SupportingFile("auth/HttpBasicAuth.mustache", authFolder, "HttpBasicAuth.java"));
189+
supportingFiles.add(new SupportingFile("auth/ApiKeyAuth.mustache", authFolder, "ApiKeyAuth.java"));
190+
supportingFiles.add(new SupportingFile("auth/OAuth.mustache", authFolder, "OAuth.java"));
191+
supportingFiles.add(new SupportingFile("auth/OAuthFlow.mustache", authFolder, "OAuthFlow.java"));
192192

193-
supportingFiles.add(new SupportingFile("auth/HttpBasicAuth.mustache", authFolder, "HttpBasicAuth.java"));
194-
supportingFiles.add(new SupportingFile("auth/ApiKeyAuth.mustache", authFolder, "ApiKeyAuth.java"));
195-
supportingFiles.add(new SupportingFile("auth/OAuth.mustache", authFolder, "OAuth.java"));
196-
supportingFiles.add(new SupportingFile("auth/OAuthFlow.mustache", authFolder, "OAuthFlow.java"));
197-
}
198193
supportingFiles.add(new SupportingFile( "gradlew.mustache", "", "gradlew") );
199194
supportingFiles.add(new SupportingFile( "gradlew.bat.mustache", "", "gradlew.bat") );
200195
supportingFiles.add(new SupportingFile( "gradle-wrapper.properties.mustache",
@@ -215,7 +210,7 @@ public void processOpts() {
215210
apiDocTemplateFiles.remove("api_doc.mustache");
216211
}
217212

218-
if (!("feign".equals(getLibrary()) || "resttemplate".equals(getLibrary()) || usesAnyRetrofitLibrary() || "google-api-client".equals(getLibrary()))) {
213+
if (!("feign".equals(getLibrary()) || "resttemplate".equals(getLibrary()) || usesAnyRetrofitLibrary())) {
219214
supportingFiles.add(new SupportingFile("apiException.mustache", invokerFolder, "ApiException.java"));
220215
supportingFiles.add(new SupportingFile("Configuration.mustache", invokerFolder, "Configuration.java"));
221216
supportingFiles.add(new SupportingFile("Pair.mustache", invokerFolder, "Pair.java"));
@@ -250,18 +245,6 @@ public void processOpts() {
250245
} else if("resttemplate".equals(getLibrary())) {
251246
additionalProperties.put("jackson", "true");
252247
supportingFiles.add(new SupportingFile("auth/Authentication.mustache", authFolder, "Authentication.java"));
253-
} else if("vertx".equals(getLibrary())) {
254-
typeMapping.put("file", "AsyncFile");
255-
importMapping.put("AsyncFile", "io.vertx.core.file.AsyncFile");
256-
setJava8Mode(true);
257-
additionalProperties.put("java8", "true");
258-
additionalProperties.put("jackson", "true");
259-
260-
apiTemplateFiles.put("apiImpl.mustache", "Impl.java");
261-
apiTemplateFiles.put("rxApiImpl.mustache", ".java");
262-
supportingFiles.remove(new SupportingFile("manifest.mustache", projectFolder, "AndroidManifest.xml"));
263-
} else if ("google-api-client".equals(getLibrary())) {
264-
additionalProperties.put("jackson", "true");
265248
} else {
266249
LOGGER.error("Unknown library option (-l/--library): " + getLibrary());
267250
}
@@ -397,16 +380,7 @@ && getBooleanValue(another, CodegenConstants.IS_PATH_PARAM_EXT_NAME)){
397380

398381
@Override
399382
public String apiFilename(String templateName, String tag) {
400-
if("vertx".equals(getLibrary())) {
401-
String suffix = apiTemplateFiles().get(templateName);
402-
String subFolder = "";
403-
if (templateName.startsWith("rx")) {
404-
subFolder = "/rxjava";
405-
}
406-
return apiFileFolder() + subFolder + '/' + toApiFilename(tag) + suffix;
407-
} else {
408-
return super.apiFilename(templateName, tag);
409-
}
383+
return super.apiFilename(templateName, tag);
410384
}
411385

412386
/**

0 commit comments

Comments
 (0)