File tree Expand file tree Collapse file tree 3 files changed +32
-7
lines changed
modules/swagger-codegen/src/main
java/com/wordnik/swagger/codegen/languages Expand file tree Collapse file tree 3 files changed +32
-7
lines changed Original file line number Diff line number Diff line change @@ -51,11 +51,13 @@ public JavaClientCodegen() {
51
51
additionalProperties .put ("artifactVersion" , artifactVersion );
52
52
53
53
supportingFiles .add (new SupportingFile ("pom.mustache" , "" , "pom.xml" ));
54
- supportingFiles .add (new SupportingFile ("apiInvoker.mustache" ,
54
+ supportingFiles .add (new SupportingFile ("apiInvoker.mustache" ,
55
55
(sourceFolder + File .separator + invokerPackage ).replace ("." , java .io .File .separator ), "ApiInvoker.java" ));
56
- supportingFiles .add (new SupportingFile ("JsonUtil.mustache" ,
56
+ supportingFiles .add (new SupportingFile ("JsonUtil.mustache" ,
57
57
(sourceFolder + File .separator + invokerPackage ).replace ("." , java .io .File .separator ), "JsonUtil.java" ));
58
- supportingFiles .add (new SupportingFile ("apiException.mustache" ,
58
+ supportingFiles .add (new SupportingFile ("StringUtil.mustache" ,
59
+ (sourceFolder + File .separator + invokerPackage ).replace ("." , java .io .File .separator ), "StringUtil.java" ));
60
+ supportingFiles .add (new SupportingFile ("apiException.mustache" ,
59
61
(sourceFolder + File .separator + invokerPackage ).replace ("." , java .io .File .separator ), "ApiException.java" ));
60
62
61
63
languageSpecificPrimitives = new HashSet <String >(
Original file line number Diff line number Diff line change
1
+ package { {invokerPackage} };
2
+
3
+ public class StringUtil {
4
+ public static boolean containsIgnoreCase(String[] array, String value) {
5
+ for (String str : array) {
6
+ if (value == null && str == null) return true ;
7
+ if (value != null && value.equalsIgnoreCase(str)) return true ;
8
+ }
9
+ return false;
10
+ }
11
+
12
+ public static String join(String[] array, String separator) {
13
+ int len = array.length;
14
+ if (len == 0) return " " ;
15
+
16
+ StringBuilder out = new StringBuilder();
17
+ out.append(array[0]);
18
+ for (int i = 1; i < len; i++) {
19
+ out.append(separator).append(array[i]);
20
+ }
21
+ return out.toString();
22
+ }
23
+ }
Original file line number Diff line number Diff line change @@ -109,13 +109,13 @@ public class ApiInvoker {
109
109
110
110
public static String selectHeaderAccept(String[] accepts) {
111
111
if (accepts.length == 0) return " application/json" ;
112
- if (Arrays.asList (accepts).contains( " application/json" )) return " application/json" ;
113
- return joinString (accepts, " ," );
112
+ if (StringUtil.containsIgnoreCase (accepts, " application/json" )) return " application/json" ;
113
+ return StringUtil.join (accepts, " ," );
114
114
}
115
115
116
116
public static String selectHeaderContentType(String[] contentTypes) {
117
117
if (contentTypes.length == 0) return " application/json" ;
118
- if (Arrays.asList (contentTypes).contains( " application/json" )) return " application/json" ;
118
+ if (StringUtil.containsIgnoreCase (contentTypes, " application/json" )) return " application/json" ;
119
119
return contentTypes[0];
120
120
}
121
121
@@ -323,4 +323,4 @@ public class ApiInvoker {
323
323
}
324
324
return hostMap.get(host);
325
325
}
326
- }
326
+ }
You can’t perform that action at this time.
0 commit comments