File tree Expand file tree Collapse file tree 3 files changed +27
-68
lines changed
samples/client/petstore/java/src/main/java/io/swagger/client Expand file tree Collapse file tree 3 files changed +27
-68
lines changed Original file line number Diff line number Diff line change @@ -109,13 +109,13 @@ public static String parameterToString(Object param) {
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 @@ private Client getClient(String host) {
323
323
}
324
324
return hostMap .get (host );
325
325
}
326
- }
326
+ }
Original file line number Diff line number Diff line change
1
+ package io .swagger .client ;
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
+ }
Load Diff This file was deleted.
You can’t perform that action at this time.
0 commit comments