Skip to content

Commit

Permalink
[Java] [apache-httpclient] Fix issue with toString causing wrong valu…
Browse files Browse the repository at this point in the history
…e with collections (#19576)

* Fix issue with toString causing wrong value with collections

With collections, calling toString will result in the value becoming [a,b] instead of just a,b.

Using the existing apiClient::parameterToString method ensures it gets parsed correctly if it is a collection

* Updated samples

---------

Co-authored-by: Rasmus Zweidorff Iversen <[email protected]>
  • Loading branch information
Rasive and Rasmus Zweidorff Iversen authored Sep 17, 2024
1 parent 30b1a74 commit fd85359
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ public class {{classname}} extends BaseApi {
{{/required}}{{/allParams}}
// create path and map variables
String localVarPath = "{{{path}}}"{{#pathParams}}
.replaceAll("\\{" + "{{baseName}}" + "\\}", apiClient.escapeString({{{paramName}}}.toString())){{/pathParams}};
.replaceAll("\\{" + "{{baseName}}" + "\\}", apiClient.escapeString(apiClient.parameterToString({{{paramName}}}))){{/pathParams}};

StringJoiner localVarQueryStringJoiner = new StringJoiner("&");
String localVarQueryParameterBaseName;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,10 +92,10 @@ public String testsPathStringPathStringIntegerPathIntegerEnumNonrefStringPathEnu

// create path and map variables
String localVarPath = "/path/string/{path_string}/integer/{path_integer}/{enum_nonref_string_path}/{enum_ref_string_path}"
.replaceAll("\\{" + "path_string" + "\\}", apiClient.escapeString(pathString.toString()))
.replaceAll("\\{" + "path_integer" + "\\}", apiClient.escapeString(pathInteger.toString()))
.replaceAll("\\{" + "enum_nonref_string_path" + "\\}", apiClient.escapeString(enumNonrefStringPath.toString()))
.replaceAll("\\{" + "enum_ref_string_path" + "\\}", apiClient.escapeString(enumRefStringPath.toString()));
.replaceAll("\\{" + "path_string" + "\\}", apiClient.escapeString(apiClient.parameterToString(pathString)))
.replaceAll("\\{" + "path_integer" + "\\}", apiClient.escapeString(apiClient.parameterToString(pathInteger)))
.replaceAll("\\{" + "enum_nonref_string_path" + "\\}", apiClient.escapeString(apiClient.parameterToString(enumNonrefStringPath)))
.replaceAll("\\{" + "enum_ref_string_path" + "\\}", apiClient.escapeString(apiClient.parameterToString(enumRefStringPath)));

StringJoiner localVarQueryStringJoiner = new StringJoiner("&");
String localVarQueryParameterBaseName;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ public void deletePet(Long petId, String apiKey, Map<String, String> additionalH

// create path and map variables
String localVarPath = "/pet/{petId}"
.replaceAll("\\{" + "petId" + "\\}", apiClient.escapeString(petId.toString()));
.replaceAll("\\{" + "petId" + "\\}", apiClient.escapeString(apiClient.parameterToString(petId)));

StringJoiner localVarQueryStringJoiner = new StringJoiner("&");
String localVarQueryParameterBaseName;
Expand Down Expand Up @@ -375,7 +375,7 @@ public Pet getPetById(Long petId, Map<String, String> additionalHeaders) throws

// create path and map variables
String localVarPath = "/pet/{petId}"
.replaceAll("\\{" + "petId" + "\\}", apiClient.escapeString(petId.toString()));
.replaceAll("\\{" + "petId" + "\\}", apiClient.escapeString(apiClient.parameterToString(petId)));

StringJoiner localVarQueryStringJoiner = new StringJoiner("&");
String localVarQueryParameterBaseName;
Expand Down Expand Up @@ -523,7 +523,7 @@ public void updatePetWithForm(Long petId, String name, String status, Map<String

// create path and map variables
String localVarPath = "/pet/{petId}"
.replaceAll("\\{" + "petId" + "\\}", apiClient.escapeString(petId.toString()));
.replaceAll("\\{" + "petId" + "\\}", apiClient.escapeString(apiClient.parameterToString(petId)));

StringJoiner localVarQueryStringJoiner = new StringJoiner("&");
String localVarQueryParameterBaseName;
Expand Down Expand Up @@ -605,7 +605,7 @@ public ModelApiResponse uploadFile(Long petId, String additionalMetadata, File _

// create path and map variables
String localVarPath = "/pet/{petId}/uploadImage"
.replaceAll("\\{" + "petId" + "\\}", apiClient.escapeString(petId.toString()));
.replaceAll("\\{" + "petId" + "\\}", apiClient.escapeString(apiClient.parameterToString(petId)));

StringJoiner localVarQueryStringJoiner = new StringJoiner("&");
String localVarQueryParameterBaseName;
Expand Down Expand Up @@ -693,7 +693,7 @@ public ModelApiResponse uploadFileWithRequiredFile(Long petId, File requiredFile

// create path and map variables
String localVarPath = "/fake/{petId}/uploadImageWithRequiredFile"
.replaceAll("\\{" + "petId" + "\\}", apiClient.escapeString(petId.toString()));
.replaceAll("\\{" + "petId" + "\\}", apiClient.escapeString(apiClient.parameterToString(petId)));

StringJoiner localVarQueryStringJoiner = new StringJoiner("&");
String localVarQueryParameterBaseName;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ public void deleteOrder(String orderId, Map<String, String> additionalHeaders) t

// create path and map variables
String localVarPath = "/store/order/{order_id}"
.replaceAll("\\{" + "order_id" + "\\}", apiClient.escapeString(orderId.toString()));
.replaceAll("\\{" + "order_id" + "\\}", apiClient.escapeString(apiClient.parameterToString(orderId)));

StringJoiner localVarQueryStringJoiner = new StringJoiner("&");
String localVarQueryParameterBaseName;
Expand Down Expand Up @@ -210,7 +210,7 @@ public Order getOrderById(Long orderId, Map<String, String> additionalHeaders) t

// create path and map variables
String localVarPath = "/store/order/{order_id}"
.replaceAll("\\{" + "order_id" + "\\}", apiClient.escapeString(orderId.toString()));
.replaceAll("\\{" + "order_id" + "\\}", apiClient.escapeString(apiClient.parameterToString(orderId)));

StringJoiner localVarQueryStringJoiner = new StringJoiner("&");
String localVarQueryParameterBaseName;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,7 @@ public void deleteUser(String username, Map<String, String> additionalHeaders) t

// create path and map variables
String localVarPath = "/user/{username}"
.replaceAll("\\{" + "username" + "\\}", apiClient.escapeString(username.toString()));
.replaceAll("\\{" + "username" + "\\}", apiClient.escapeString(apiClient.parameterToString(username)));

StringJoiner localVarQueryStringJoiner = new StringJoiner("&");
String localVarQueryParameterBaseName;
Expand Down Expand Up @@ -357,7 +357,7 @@ public User getUserByName(String username, Map<String, String> additionalHeaders

// create path and map variables
String localVarPath = "/user/{username}"
.replaceAll("\\{" + "username" + "\\}", apiClient.escapeString(username.toString()));
.replaceAll("\\{" + "username" + "\\}", apiClient.escapeString(apiClient.parameterToString(username)));

StringJoiner localVarQueryStringJoiner = new StringJoiner("&");
String localVarQueryParameterBaseName;
Expand Down Expand Up @@ -584,7 +584,7 @@ public void updateUser(String username, User user, Map<String, String> additiona

// create path and map variables
String localVarPath = "/user/{username}"
.replaceAll("\\{" + "username" + "\\}", apiClient.escapeString(username.toString()));
.replaceAll("\\{" + "username" + "\\}", apiClient.escapeString(apiClient.parameterToString(username)));

StringJoiner localVarQueryStringJoiner = new StringJoiner("&");
String localVarQueryParameterBaseName;
Expand Down

0 comments on commit fd85359

Please sign in to comment.