Skip to content

Commit aecb4ad

Browse files
committed
Merge pull request #791 from xhh/java-api-client
[Java] Make API client more pluggable
2 parents 2662167 + cf4b4de commit aecb4ad

File tree

14 files changed

+570
-335
lines changed

14 files changed

+570
-335
lines changed

modules/swagger-codegen/src/main/java/com/wordnik/swagger/codegen/languages/JavaClientCodegen.java

Lines changed: 20 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -36,12 +36,12 @@ public JavaClientCodegen() {
3636

3737
reservedWords = new HashSet<String> (
3838
Arrays.asList(
39-
"abstract", "continue", "for", "new", "switch", "assert",
40-
"default", "if", "package", "synchronized", "boolean", "do", "goto", "private",
41-
"this", "break", "double", "implements", "protected", "throw", "byte", "else",
42-
"import", "public", "throws", "case", "enum", "instanceof", "return", "transient",
43-
"catch", "extends", "int", "short", "try", "char", "final", "interface", "static",
44-
"void", "class", "finally", "long", "strictfp", "volatile", "const", "float",
39+
"abstract", "continue", "for", "new", "switch", "assert",
40+
"default", "if", "package", "synchronized", "boolean", "do", "goto", "private",
41+
"this", "break", "double", "implements", "protected", "throw", "byte", "else",
42+
"import", "public", "throws", "case", "enum", "instanceof", "return", "transient",
43+
"catch", "extends", "int", "short", "try", "char", "final", "interface", "static",
44+
"void", "class", "finally", "long", "strictfp", "volatile", "const", "float",
4545
"native", "super", "while")
4646
);
4747

@@ -58,7 +58,7 @@ public JavaClientCodegen() {
5858
);
5959
instantiationTypes.put("array", "ArrayList");
6060
instantiationTypes.put("map", "HashMap");
61-
61+
6262
cliOptions.add(new CliOption("invokerPackage", "root package for generated code"));
6363
cliOptions.add(new CliOption("groupId", "groupId in generated pom.xml"));
6464
cliOptions.add(new CliOption("artifactId", "artifactId in generated pom.xml"));
@@ -69,53 +69,55 @@ public JavaClientCodegen() {
6969
@Override
7070
public void processOpts() {
7171
super.processOpts();
72-
72+
7373
if(additionalProperties.containsKey("invokerPackage")) {
7474
this.setInvokerPackage((String)additionalProperties.get("invokerPackage"));
7575
}
7676
else{
7777
//not set, use default to be passed to template
7878
additionalProperties.put("invokerPackage", invokerPackage);
7979
}
80-
80+
8181
if(additionalProperties.containsKey("groupId")) {
8282
this.setGroupId((String)additionalProperties.get("groupId"));
8383
}
8484
else{
8585
//not set, use to be passed to template
8686
additionalProperties.put("groupId", groupId);
8787
}
88-
88+
8989
if(additionalProperties.containsKey("artifactId")) {
9090
this.setArtifactId((String)additionalProperties.get("artifactId"));
9191
}
9292
else{
9393
//not set, use to be passed to template
9494
additionalProperties.put("artifactId", artifactId);
9595
}
96-
96+
9797
if(additionalProperties.containsKey("artifactVersion")) {
9898
this.setArtifactVersion((String)additionalProperties.get("artifactVersion"));
9999
}
100100
else{
101101
//not set, use to be passed to template
102102
additionalProperties.put("artifactVersion", artifactVersion);
103103
}
104-
104+
105105
if(additionalProperties.containsKey("sourceFolder")) {
106106
this.setSourceFolder((String)additionalProperties.get("sourceFolder"));
107107
}
108108

109109
supportingFiles.add(new SupportingFile("pom.mustache", "", "pom.xml"));
110-
supportingFiles.add(new SupportingFile("apiInvoker.mustache",
111-
(sourceFolder + File.separator + invokerPackage).replace(".", java.io.File.separator), "ApiInvoker.java"));
112-
supportingFiles.add(new SupportingFile("JsonUtil.mustache",
110+
supportingFiles.add(new SupportingFile("ApiClient.mustache",
111+
(sourceFolder + File.separator + invokerPackage).replace(".", java.io.File.separator), "ApiClient.java"));
112+
supportingFiles.add(new SupportingFile("Configuration.mustache",
113+
(sourceFolder + File.separator + invokerPackage).replace(".", java.io.File.separator), "Configuration.java"));
114+
supportingFiles.add(new SupportingFile("JsonUtil.mustache",
113115
(sourceFolder + File.separator + invokerPackage).replace(".", java.io.File.separator), "JsonUtil.java"));
114-
supportingFiles.add(new SupportingFile("apiException.mustache",
116+
supportingFiles.add(new SupportingFile("apiException.mustache",
115117
(sourceFolder + File.separator + invokerPackage).replace(".", java.io.File.separator), "ApiException.java"));
116118
}
117-
118-
119+
120+
119121

120122
@Override
121123
public String escapeReservedWord(String name) {

0 commit comments

Comments
 (0)