mirror of
https://github.com/OpenAPITools/openapi-generator.git
synced 2025-12-18 21:47:04 +00:00
[java][okhttp-gson] minor improvements (#13792)
* use replace instead of replaceAll * avoid using instance to accessd static methods * use entrySet instead of keySet * use statis class instead of instance for static method * update samples
This commit is contained in:
@@ -366,7 +366,7 @@ public class ApiClient {
|
||||
* @return a {@link org.openapitools.client.ApiClient} object
|
||||
*/
|
||||
public ApiClient setDateFormat(DateFormat dateFormat) {
|
||||
this.json.setDateFormat(dateFormat);
|
||||
JSON.setDateFormat(dateFormat);
|
||||
return this;
|
||||
}
|
||||
|
||||
@@ -377,7 +377,7 @@ public class ApiClient {
|
||||
* @return a {@link org.openapitools.client.ApiClient} object
|
||||
*/
|
||||
public ApiClient setSqlDateFormat(DateFormat dateFormat) {
|
||||
this.json.setSqlDateFormat(dateFormat);
|
||||
JSON.setSqlDateFormat(dateFormat);
|
||||
return this;
|
||||
}
|
||||
|
||||
@@ -388,7 +388,7 @@ public class ApiClient {
|
||||
* @return a {@link org.openapitools.client.ApiClient} object
|
||||
*/
|
||||
public ApiClient setOffsetDateTimeFormat(DateTimeFormatter dateFormat) {
|
||||
this.json.setOffsetDateTimeFormat(dateFormat);
|
||||
JSON.setOffsetDateTimeFormat(dateFormat);
|
||||
return this;
|
||||
}
|
||||
|
||||
@@ -399,7 +399,7 @@ public class ApiClient {
|
||||
* @return a {@link org.openapitools.client.ApiClient} object
|
||||
*/
|
||||
public ApiClient setLocalDateFormat(DateTimeFormatter dateFormat) {
|
||||
this.json.setLocalDateFormat(dateFormat);
|
||||
JSON.setLocalDateFormat(dateFormat);
|
||||
return this;
|
||||
}
|
||||
|
||||
@@ -410,7 +410,7 @@ public class ApiClient {
|
||||
* @return a {@link org.openapitools.client.ApiClient} object
|
||||
*/
|
||||
public ApiClient setLenientOnJson(boolean lenientOnJson) {
|
||||
this.json.setLenientOnJson(lenientOnJson);
|
||||
JSON.setLenientOnJson(lenientOnJson);
|
||||
return this;
|
||||
}
|
||||
|
||||
@@ -704,7 +704,7 @@ public class ApiClient {
|
||||
return "";
|
||||
} else if (param instanceof Date || param instanceof OffsetDateTime || param instanceof LocalDate) {
|
||||
//Serialize to json string and remove the " enclosing characters
|
||||
String jsonStr = json.serialize(param);
|
||||
String jsonStr = JSON.serialize(param);
|
||||
return jsonStr.substring(1, jsonStr.length() - 1);
|
||||
} else if (param instanceof Collection) {
|
||||
StringBuilder b = new StringBuilder();
|
||||
@@ -963,7 +963,7 @@ public class ApiClient {
|
||||
contentType = "application/json";
|
||||
}
|
||||
if (isJsonMime(contentType)) {
|
||||
return json.deserialize(respBody, returnType);
|
||||
return JSON.deserialize(respBody, returnType);
|
||||
} else if (returnType.equals(String.class)) {
|
||||
// Expecting string, return the raw response body.
|
||||
return (T) respBody;
|
||||
@@ -997,7 +997,7 @@ public class ApiClient {
|
||||
} else if (isJsonMime(contentType)) {
|
||||
String content;
|
||||
if (obj != null) {
|
||||
content = json.serialize(obj);
|
||||
content = JSON.serialize(obj);
|
||||
} else {
|
||||
content = null;
|
||||
}
|
||||
@@ -1476,7 +1476,7 @@ public class ApiClient {
|
||||
} else {
|
||||
String content;
|
||||
if (obj != null) {
|
||||
content = json.serialize(obj);
|
||||
content = JSON.serialize(obj);
|
||||
} else {
|
||||
content = null;
|
||||
}
|
||||
|
||||
@@ -228,7 +228,7 @@ public class PetApi {
|
||||
|
||||
// create path and map variables
|
||||
String localVarPath = "/pet/{petId}"
|
||||
.replaceAll("\\{" + "petId" + "\\}", localVarApiClient.escapeString(petId.toString()));
|
||||
.replace("{" + "petId" + "}", localVarApiClient.escapeString(petId.toString()));
|
||||
|
||||
List<Pair> localVarQueryParams = new ArrayList<Pair>();
|
||||
List<Pair> localVarCollectionQueryParams = new ArrayList<Pair>();
|
||||
@@ -637,7 +637,7 @@ public class PetApi {
|
||||
|
||||
// create path and map variables
|
||||
String localVarPath = "/pet/{petId}"
|
||||
.replaceAll("\\{" + "petId" + "\\}", localVarApiClient.escapeString(petId.toString()));
|
||||
.replace("{" + "petId" + "}", localVarApiClient.escapeString(petId.toString()));
|
||||
|
||||
List<Pair> localVarQueryParams = new ArrayList<Pair>();
|
||||
List<Pair> localVarCollectionQueryParams = new ArrayList<Pair>();
|
||||
@@ -902,7 +902,7 @@ public class PetApi {
|
||||
|
||||
// create path and map variables
|
||||
String localVarPath = "/pet/{petId}"
|
||||
.replaceAll("\\{" + "petId" + "\\}", localVarApiClient.escapeString(petId.toString()));
|
||||
.replace("{" + "petId" + "}", localVarApiClient.escapeString(petId.toString()));
|
||||
|
||||
List<Pair> localVarQueryParams = new ArrayList<Pair>();
|
||||
List<Pair> localVarCollectionQueryParams = new ArrayList<Pair>();
|
||||
@@ -1041,7 +1041,7 @@ public class PetApi {
|
||||
|
||||
// create path and map variables
|
||||
String localVarPath = "/pet/{petId}/uploadImage"
|
||||
.replaceAll("\\{" + "petId" + "\\}", localVarApiClient.escapeString(petId.toString()));
|
||||
.replace("{" + "petId" + "}", localVarApiClient.escapeString(petId.toString()));
|
||||
|
||||
List<Pair> localVarQueryParams = new ArrayList<Pair>();
|
||||
List<Pair> localVarCollectionQueryParams = new ArrayList<Pair>();
|
||||
@@ -1184,7 +1184,7 @@ public class PetApi {
|
||||
|
||||
// create path and map variables
|
||||
String localVarPath = "/fake/{petId}/uploadImageWithRequiredFile"
|
||||
.replaceAll("\\{" + "petId" + "\\}", localVarApiClient.escapeString(petId.toString()));
|
||||
.replace("{" + "petId" + "}", localVarApiClient.escapeString(petId.toString()));
|
||||
|
||||
List<Pair> localVarQueryParams = new ArrayList<Pair>();
|
||||
List<Pair> localVarCollectionQueryParams = new ArrayList<Pair>();
|
||||
|
||||
@@ -104,7 +104,7 @@ public class StoreApi {
|
||||
|
||||
// create path and map variables
|
||||
String localVarPath = "/store/order/{order_id}"
|
||||
.replaceAll("\\{" + "order_id" + "\\}", localVarApiClient.escapeString(orderId.toString()));
|
||||
.replace("{" + "order_id" + "}", localVarApiClient.escapeString(orderId.toString()));
|
||||
|
||||
List<Pair> localVarQueryParams = new ArrayList<Pair>();
|
||||
List<Pair> localVarCollectionQueryParams = new ArrayList<Pair>();
|
||||
@@ -349,7 +349,7 @@ public class StoreApi {
|
||||
|
||||
// create path and map variables
|
||||
String localVarPath = "/store/order/{order_id}"
|
||||
.replaceAll("\\{" + "order_id" + "\\}", localVarApiClient.escapeString(orderId.toString()));
|
||||
.replace("{" + "order_id" + "}", localVarApiClient.escapeString(orderId.toString()));
|
||||
|
||||
List<Pair> localVarQueryParams = new ArrayList<Pair>();
|
||||
List<Pair> localVarCollectionQueryParams = new ArrayList<Pair>();
|
||||
|
||||
@@ -471,7 +471,7 @@ public class UserApi {
|
||||
|
||||
// create path and map variables
|
||||
String localVarPath = "/user/{username}"
|
||||
.replaceAll("\\{" + "username" + "\\}", localVarApiClient.escapeString(username.toString()));
|
||||
.replace("{" + "username" + "}", localVarApiClient.escapeString(username.toString()));
|
||||
|
||||
List<Pair> localVarQueryParams = new ArrayList<Pair>();
|
||||
List<Pair> localVarCollectionQueryParams = new ArrayList<Pair>();
|
||||
@@ -599,7 +599,7 @@ public class UserApi {
|
||||
|
||||
// create path and map variables
|
||||
String localVarPath = "/user/{username}"
|
||||
.replaceAll("\\{" + "username" + "\\}", localVarApiClient.escapeString(username.toString()));
|
||||
.replace("{" + "username" + "}", localVarApiClient.escapeString(username.toString()));
|
||||
|
||||
List<Pair> localVarQueryParams = new ArrayList<Pair>();
|
||||
List<Pair> localVarCollectionQueryParams = new ArrayList<Pair>();
|
||||
@@ -994,7 +994,7 @@ public class UserApi {
|
||||
|
||||
// create path and map variables
|
||||
String localVarPath = "/user/{username}"
|
||||
.replaceAll("\\{" + "username" + "\\}", localVarApiClient.escapeString(username.toString()));
|
||||
.replace("{" + "username" + "}", localVarApiClient.escapeString(username.toString()));
|
||||
|
||||
List<Pair> localVarQueryParams = new ArrayList<Pair>();
|
||||
List<Pair> localVarCollectionQueryParams = new ArrayList<Pair>();
|
||||
|
||||
@@ -65,8 +65,8 @@ public class RetryingOAuth extends OAuth implements Interceptor {
|
||||
.setClientSecret(clientSecret));
|
||||
setFlow(flow);
|
||||
if (parameters != null) {
|
||||
for (String paramName : parameters.keySet()) {
|
||||
tokenRequestBuilder.setParameter(paramName, parameters.get(paramName));
|
||||
for (Map.Entry<String, String> entry : parameters.entrySet()) {
|
||||
tokenRequestBuilder.setParameter(entry.getKey(), entry.getValue());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -129,8 +129,8 @@ public class RetryingOAuth extends OAuth implements Interceptor {
|
||||
}
|
||||
|
||||
Map<String, String> headers = oAuthRequest.getHeaders();
|
||||
for (String headerName : headers.keySet()) {
|
||||
requestBuilder.addHeader(headerName, headers.get(headerName));
|
||||
for (Map.Entry<String, String> entry : headers.entrySet()) {
|
||||
requestBuilder.addHeader(entry.getKey(), entry.getValue());
|
||||
}
|
||||
requestBuilder.url(oAuthRequest.getLocationUri());
|
||||
|
||||
|
||||
Reference in New Issue
Block a user