-
Notifications
You must be signed in to change notification settings - Fork 21
fix(java): use Map for query parameters #484
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 2 commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
a0b6c74
fix(java): use Map for query parameters
shortcuts 27f5aa7
Merge branch 'main' into fix/java-query-parameters
shortcuts 1657a3a
remove unused code
shortcuts bd9eb13
Merge branch 'main' into fix/java-query-parameters
shortcuts 3f2680c
regen tests for Predict
shortcuts File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -534,7 +534,7 @@ public class ApiClient { | |
* @return The HTTP call | ||
* @throws AlgoliaRuntimeException If fail to serialize the request body object | ||
*/ | ||
public Call buildCall(String path, String method, List<Pair> queryParams, Object body, Map<String, String> headerParams, ApiCallback callback) throws AlgoliaRuntimeException { | ||
public Call buildCall(String path, String method, Map<String, String> queryParams, Object body, Map<String, String> headerParams, ApiCallback callback) throws AlgoliaRuntimeException { | ||
Request request = buildRequest(path, method, queryParams, body, headerParams, callback); | ||
|
||
return requester.newCall(request); | ||
|
@@ -552,19 +552,17 @@ public class ApiClient { | |
* @return The HTTP request | ||
* @throws AlgoliaRuntimeException If fail to serialize the request body object | ||
*/ | ||
public Request buildRequest(String path, String method, List<Pair> queryParams, Object body, Map<String, String> headerParams, ApiCallback callback) throws AlgoliaRuntimeException { | ||
public Request buildRequest(String path, String method, Map<String, String> queryParams, Object body, Map<String, String> headerParams, ApiCallback callback) throws AlgoliaRuntimeException { | ||
headerParams.put("X-Algolia-Application-Id", this.appId); | ||
headerParams.put("X-Algolia-API-Key", this.apiKey); | ||
headerParams.put("Accept", "application/json"); | ||
headerParams.put("Content-Type", "application/json"); | ||
|
||
final String url = buildUrl(path, queryParams); | ||
final Request.Builder reqBuilder = new Request.Builder().url(url); | ||
processHeaderParams(headerParams, reqBuilder); | ||
|
||
String contentType = (String) headerParams.get("Content-Type"); | ||
// ensuring a default content type | ||
if (contentType == null) { | ||
contentType = "application/json"; | ||
} | ||
Comment on lines
-564
to
-567
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Since we set it right above, it can't be null |
||
|
||
RequestBody reqBody; | ||
if (!HttpMethod.permitsRequestBody(method)) { | ||
|
@@ -604,7 +602,7 @@ public class ApiClient { | |
* @param queryParams The query parameters | ||
* @return The full URL | ||
*/ | ||
public String buildUrl(String path, List<Pair> queryParams) { | ||
public String buildUrl(String path, Map<String, String> queryParams) { | ||
final StringBuilder url = new StringBuilder(); | ||
|
||
//The real host will be assigned by the retry strategy | ||
|
@@ -613,7 +611,7 @@ public class ApiClient { | |
if (queryParams != null && !queryParams.isEmpty()) { | ||
// support (constant) query string in `path`, e.g. "/posts?draft=1" | ||
String prefix = path.contains("?") ? "&" : "?"; | ||
for (Pair param : queryParams) { | ||
for (Entry<String, String> param : queryParams.entrySet()) { | ||
if (param.getValue() != null) { | ||
if (prefix != null) { | ||
url.append(prefix); | ||
|
@@ -622,7 +620,7 @@ public class ApiClient { | |
url.append("&"); | ||
} | ||
String value = parameterToString(param.getValue()); | ||
url.append(escapeString(param.getName())).append("=").append(escapeString(value)); | ||
url.append(escapeString(param.getKey())).append("=").append(escapeString(value)); | ||
} | ||
} | ||
} | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -149,6 +149,7 @@ export function create{{capitalizedApiName}}(options: CreateClientOptions{{#hasR | |
{{/queryParams.0}} | ||
{{/bodyParams.0}} | ||
{{/allParams.0}} | ||
* @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This was missing in the JS client |
||
*/ | ||
{{nickname}}( | ||
{{#allParams.0}} | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Those were in every methods so I've moved them here