7171/** ApiClient class. */
7272@ javax .annotation .Generated (
7373 value = "org.openapitools.codegen.languages.JavaClientCodegen" ,
74- comments = "Generator version: 7.12 .0" )
74+ comments = "Generator version: 7.26 .0" )
7575public class ApiClient extends JavaTimeFormatter {
76- private static final Pattern JSON_MIME_PATTERN =
76+ protected static final Pattern JSON_MIME_PATTERN =
7777 Pattern .compile ("(?i)^(application/json|[^;/ \t ]+/[^;/ \t ]+[+]json)[ \t ]*(;.*)?$" );
7878
7979 protected Map <String , String > defaultHeaderMap = new HashMap <>();
8080 protected Map <String , String > defaultCookieMap = new HashMap <>();
8181 protected String basePath = "https://api.hellosign.com/v3" ;
8282 protected String userAgent ;
83- private static final Logger log = Logger .getLogger (ApiClient .class .getName ());
83+ protected static final Logger log = Logger .getLogger (ApiClient .class .getName ());
8484
8585 protected List <ServerConfiguration > servers =
8686 new ArrayList <>(
@@ -119,7 +119,7 @@ public class ApiClient extends JavaTimeFormatter {
119119 protected boolean debugging = false ;
120120 protected ClientConfig clientConfig ;
121121 protected int connectionTimeout = 0 ;
122- private int readTimeout = 0 ;
122+ protected int readTimeout = 0 ;
123123
124124 protected Client httpClient ;
125125 protected JSON json ;
@@ -287,7 +287,7 @@ public ApiClient setServerVariables(Map<String, String> serverVariables) {
287287 return this ;
288288 }
289289
290- private void updateBasePath () {
290+ protected void updateBasePath () {
291291 if (serverIndex != null ) {
292292 setBasePath (servers .get (serverIndex ).URL (serverVariables ));
293293 }
@@ -463,6 +463,7 @@ public boolean isDebugging() {
463463 */
464464 public ApiClient setDebugging (boolean debugging ) {
465465 this .debugging = debugging ;
466+ applyDebugSetting (this .clientConfig );
466467 // Rebuild HTTP Client according to the new "debugging" value.
467468 this .httpClient = buildHttpClient ();
468469 return this ;
@@ -734,6 +735,41 @@ public String escapeString(String str) {
734735 }
735736 }
736737
738+ /**
739+ * Format the given collection as a path parameter value according to the collection format.
740+ * Each item is escaped individually, so that the delimiter is preserved (e.g. "a,b,c" for csv).
741+ *
742+ * @param collectionFormat Collection format (csv by default)
743+ * @param value Collection value
744+ * @return Escaped path parameter value
745+ */
746+ public String collectionPathParameterToString (String collectionFormat , Collection <?> value ) {
747+ if (value == null || value .isEmpty ()) {
748+ return "" ;
749+ }
750+
751+ // "multi" is not valid for path params, fall back to csv
752+ String delimiter = "," ;
753+ if ("ssv" .equals (collectionFormat )) {
754+ delimiter = escapeString (" " );
755+ } else if ("tsv" .equals (collectionFormat )) {
756+ delimiter = escapeString ("\t " );
757+ } else if ("pipes" .equals (collectionFormat )) {
758+ delimiter = escapeString ("|" );
759+ }
760+
761+ StringBuilder sb = new StringBuilder ();
762+ boolean first = true ;
763+ for (Object item : value ) {
764+ if (!first ) {
765+ sb .append (delimiter );
766+ }
767+ sb .append (escapeString (parameterToString (item )));
768+ first = false ;
769+ }
770+ return sb .toString ();
771+ }
772+
737773 /**
738774 * Serialize the given Java object into string entity according the given Content-Type (only
739775 * JSON is supported for now).
@@ -814,7 +850,7 @@ public Entity<?> serialize(
814850 * @param key Key of the object
815851 * @param multiPart MultiPart to add the form param to
816852 */
817- private void addParamToMultipart (Object value , String key , MultiPart multiPart ) {
853+ protected void addParamToMultipart (Object value , String key , MultiPart multiPart ) {
818854 if (value instanceof File ) {
819855 File file = (File ) value ;
820856 FormDataContentDisposition contentDisp =
@@ -1021,9 +1057,11 @@ public <T> ApiResponse<T> invokeAPI(
10211057 if (index < 0 || index >= serverConfigurations .size ()) {
10221058 throw new ArrayIndexOutOfBoundsException (
10231059 String .format (
1060+ java .util .Locale .ROOT ,
10241061 "Invalid index %d when selecting the host settings. Must be less"
10251062 + " than %d" ,
1026- index , serverConfigurations .size ()));
1063+ index ,
1064+ serverConfigurations .size ()));
10271065 }
10281066 targetURL = serverConfigurations .get (index ).URL (variables ) + path ;
10291067 } else {
@@ -1033,6 +1071,22 @@ public <T> ApiResponse<T> invokeAPI(
10331071 // to support (constant) query string in `path`, e.g. "/posts?draft=1"
10341072 WebTarget target = httpClient .target (targetURL );
10351073
1074+ // put all headers in one place
1075+ Map <String , String > allHeaderParams = new HashMap <>(defaultHeaderMap );
1076+ allHeaderParams .putAll (headerParams );
1077+
1078+ if (authNames != null ) {
1079+ // update different parameters (e.g. headers) for authentication
1080+ updateParamsForAuth (
1081+ authNames ,
1082+ queryParams ,
1083+ allHeaderParams ,
1084+ cookieParams ,
1085+ null ,
1086+ method ,
1087+ target .getUri ());
1088+ }
1089+
10361090 if (queryParams != null ) {
10371091 for (Pair queryParam : queryParams ) {
10381092 if (queryParam .getValue () != null ) {
@@ -1065,22 +1119,6 @@ public <T> ApiResponse<T> invokeAPI(
10651119
10661120 Entity <?> entity = serialize (body , formParams , contentType , isBodyNullable );
10671121
1068- // put all headers in one place
1069- Map <String , String > allHeaderParams = new HashMap <>(defaultHeaderMap );
1070- allHeaderParams .putAll (headerParams );
1071-
1072- if (authNames != null ) {
1073- // update different parameters (e.g. headers) for authentication
1074- updateParamsForAuth (
1075- authNames ,
1076- queryParams ,
1077- allHeaderParams ,
1078- cookieParams ,
1079- null ,
1080- method ,
1081- target .getUri ());
1082- }
1083-
10841122 for (Entry <String , String > entry : allHeaderParams .entrySet ()) {
10851123 String value = entry .getValue ();
10861124 if (value != null ) {
@@ -1142,7 +1180,7 @@ public <T> ApiResponse<T> invokeAPI(
11421180 }
11431181 }
11441182
1145- private Response sendRequest (
1183+ protected Response sendRequest (
11461184 String method , Invocation .Builder invocationBuilder , Entity <?> entity ) {
11471185 Response response ;
11481186 if ("POST" .equals (method )) {
@@ -1203,8 +1241,10 @@ public <T> ApiResponse<T> invokeAPI(
12031241 * @return Client
12041242 */
12051243 protected Client buildHttpClient () {
1206- // recreate the client config to pickup changes
1207- clientConfig = getDefaultClientConfig ();
1244+ // Create ClientConfig if it has not been initialized yet
1245+ if (clientConfig == null ) {
1246+ clientConfig = getDefaultClientConfig ();
1247+ }
12081248
12091249 ClientBuilder clientBuilder = ClientBuilder .newBuilder ();
12101250 clientBuilder = clientBuilder .withConfig (clientConfig );
@@ -1225,6 +1265,11 @@ public ClientConfig getDefaultClientConfig() {
12251265 clientConfig .property (HttpUrlConnectorProvider .SET_METHOD_WORKAROUND , true );
12261266 // turn off compliance validation to be able to send payloads with DELETE calls
12271267 clientConfig .property (ClientProperties .SUPPRESS_HTTP_COMPLIANCE_VALIDATION , true );
1268+ applyDebugSetting (clientConfig );
1269+ return clientConfig ;
1270+ }
1271+
1272+ protected void applyDebugSetting (ClientConfig clientConfig ) {
12281273 if (debugging ) {
12291274 clientConfig .register (
12301275 new LoggingFeature (
@@ -1242,8 +1287,6 @@ public ClientConfig getDefaultClientConfig() {
12421287 java .util .logging .Logger .getLogger ("org.glassfish.jersey.client" )
12431288 .setLevel (java .util .logging .Level .SEVERE );
12441289 }
1245-
1246- return clientConfig ;
12471290 }
12481291
12491292 /**
0 commit comments