Skip to content

Commit 8483b34

Browse files
committed
fix(templates): make queryParameters naming consistent
1 parent ee9c021 commit 8483b34

File tree

5 files changed

+39
-39
lines changed

5 files changed

+39
-39
lines changed

clients/algoliasearch-client-java-2/algoliasearch-core/src/main/java/com/algolia/utils/RequestOptions.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
public class RequestOptions {
1212

1313
private final Map<String, String> headers = new HashMap<String, String>();
14-
private final Map<String, String> queryParams = new HashMap<String, String>();
14+
private final Map<String, String> queryParameters = new HashMap<String, String>();
1515
private Integer timeout = null;
1616

1717
public RequestOptions addExtraHeader(
@@ -26,16 +26,16 @@ public RequestOptions addExtraQueryParameters(
2626
@Nonnull String key,
2727
@Nonnull String value
2828
) {
29-
queryParams.put(key, value);
29+
queryParameters.put(key, value);
3030
return this;
3131
}
3232

3333
public Map<String, String> getExtraHeaders() {
3434
return headers;
3535
}
3636

37-
public Map<String, String> getExtraQueryParams() {
38-
return queryParams;
37+
public Map<String, String> getExtraQueryParameters() {
38+
return queryParameters;
3939
}
4040

4141
public Integer getTimeout() {
@@ -53,8 +53,8 @@ public String toString() {
5353
"RequestOptions{" +
5454
"headers=" +
5555
headers +
56-
", queryParams=" +
57-
queryParams +
56+
", queryParameters=" +
57+
queryParameters +
5858
'\'' +
5959
'}'
6060
);

templates/java/libraries/okhttp-gson/ApiClient.mustache

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -266,15 +266,15 @@ public class ApiClient {
266266
*
267267
* @param path The sub-path of the HTTP URL
268268
* @param method The request method, one of "GET", "HEAD", "OPTIONS", "POST", "PUT", "PATCH" and "DELETE"
269-
* @param queryParams The query parameters
269+
* @param queryParameters The query parameters
270270
* @param body The request body object
271271
* @param headerParams The header parameters
272272
* @param requestOptions The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
273273
* @return The HTTP call
274274
* @throws AlgoliaRuntimeException If fail to serialize the request body object
275275
*/
276-
public Call buildCall(String path, String method, Map<String, String> queryParams, Object body, Map<String, String> headerParams, RequestOptions requestOptions) throws AlgoliaRuntimeException {
277-
Request request = buildRequest(path, method, queryParams, body, headerParams, requestOptions);
276+
public Call buildCall(String path, String method, Map<String, String> queryParameters, Object body, Map<String, String> headerParams, RequestOptions requestOptions) throws AlgoliaRuntimeException {
277+
Request request = buildRequest(path, method, queryParameters, body, headerParams, requestOptions);
278278
279279
return requester.newCall(request);
280280
}
@@ -284,19 +284,19 @@ public class ApiClient {
284284
*
285285
* @param path The sub-path of the HTTP URL
286286
* @param method The request method, one of "GET", "HEAD", "OPTIONS", "POST", "PUT", "PATCH" and "DELETE"
287-
* @param queryParams The query parameters
287+
* @param queryParameters The query parameters
288288
* @param body The request body object
289289
* @param headerParams The header parameters
290290
* @param requestOptions The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
291291
* @return The HTTP request
292292
* @throws AlgoliaRuntimeException If fail to serialize the request body object
293293
*/
294-
public Request buildRequest(String path, String method, Map<String, String> queryParams, Object body, Map<String, String> headerParams, RequestOptions requestOptions) throws AlgoliaRuntimeException {
294+
public Request buildRequest(String path, String method, Map<String, String> queryParameters, Object body, Map<String, String> headerParams, RequestOptions requestOptions) throws AlgoliaRuntimeException {
295295
boolean hasRequestOptions = requestOptions != null;
296296
final String url = buildUrl(
297297
path,
298-
queryParams,
299-
hasRequestOptions ? requestOptions.getExtraQueryParams() : null
298+
queryParameters,
299+
hasRequestOptions ? requestOptions.getExtraQueryParameters() : null
300300
);
301301
final Request.Builder reqBuilder = new Request.Builder().url(url);
302302
processHeaderParams(
@@ -327,18 +327,18 @@ public class ApiClient {
327327
* Build full URL by concatenating base path, the given sub path and query parameters.
328328
*
329329
* @param path The sub path
330-
* @param queryParams The query parameters
331-
* @param extraQueryParams The query parameters, coming from the requestOptions
330+
* @param queryParameters The query parameters
331+
* @param extraQueryParameters The query parameters, coming from the requestOptions
332332
* @return The full URL
333333
*/
334-
public String buildUrl(String path, Map<String, String> queryParams, Map<String, String> extraQueryParams) {
334+
public String buildUrl(String path, Map<String, String> queryParameters, Map<String, String> extraQueryParameters) {
335335
StringBuilder url = new StringBuilder();
336336
337337
//The real host will be assigned by the retry strategy
338338
url.append("http://temp.path").append(path);
339339
340-
url = parseQueryParameters(path, url, queryParams);
341-
url = parseQueryParameters(path, url, extraQueryParams);
340+
url = parseQueryParameters(path, url, queryParameters);
341+
url = parseQueryParameters(path, url, extraQueryParameters);
342342
343343
return url.toString();
344344
}
@@ -347,19 +347,19 @@ public class ApiClient {
347347
* Parses the given map of Query Parameters to a given URL.
348348
*
349349
* @param path The sub path
350-
* @param url The url to add queryParams to
351-
* @param queryParams The query parameters
350+
* @param url The url to add queryParameters to
351+
* @param queryParameters The query parameters
352352
* @return The URL
353353
*/
354354
public StringBuilder parseQueryParameters(
355355
String path,
356356
StringBuilder url,
357-
Map<String, String> queryParams
357+
Map<String, String> queryParameters
358358
) {
359-
if (queryParams != null && !queryParams.isEmpty()) {
359+
if (queryParameters != null && !queryParameters.isEmpty()) {
360360
// support (constant) query string in `path`, e.g. "/posts?draft=1"
361361
String prefix = path.contains("?") ? "&" : "?";
362-
for (Entry<String, String> param : queryParams.entrySet()) {
362+
for (Entry<String, String> param : queryParameters.entrySet()) {
363363
if (param.getValue() != null) {
364364
if (prefix != null) {
365365
url.append(prefix);

templates/java/libraries/okhttp-gson/api.mustache

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -170,17 +170,17 @@ public class {{classname}} extends ApiClient {
170170
{{#x-is-custom-request}}{{{paramName}}}.toString(){{/x-is-custom-request}}{{^x-is-custom-request}}this.escapeString({{{paramName}}}.toString()){{/x-is-custom-request}}
171171
){{/pathParams}}{{/vendorExtensions}};
172172

173-
{{javaUtilPrefix}}Map<String, String> queryParams = new {{javaUtilPrefix}}HashMap<String, String>();
173+
{{javaUtilPrefix}}Map<String, String> queryParameters = new {{javaUtilPrefix}}HashMap<String, String>();
174174
{{javaUtilPrefix}}Map<String, String> headers = new {{javaUtilPrefix}}HashMap<String, String>();
175175

176176
{{#vendorExtensions}}{{#queryParams}}
177177
if ({{paramName}} != null) {
178178
{{^x-is-custom-request}}
179-
queryParams.put("{{baseName}}", parameterToString({{paramName}}));
179+
queryParameters.put("{{baseName}}", parameterToString({{paramName}}));
180180
{{/x-is-custom-request}}
181181
{{#x-is-custom-request}}
182182
for (Map.Entry<String, Object> parameter : parameters.entrySet()) {
183-
queryParams.put(parameter.getKey().toString(), parameterToString(parameter.getValue()));
183+
queryParameters.put(parameter.getKey().toString(), parameterToString(parameter.getValue()));
184184
}
185185
{{/x-is-custom-request}}
186186
}
@@ -192,7 +192,7 @@ public class {{classname}} extends ApiClient {
192192
}
193193

194194
{{/headerParams}}
195-
Call call = this.buildCall(requestPath, "{{httpMethod}}", queryParams, bodyObj, headers, requestOptions);
195+
Call call = this.buildCall(requestPath, "{{httpMethod}}", queryParameters, bodyObj, headers, requestOptions);
196196
Type returnType = new TypeToken<{{{returnType}}}>() {}.getType();
197197
return this.executeAsync(call, returnType);
198198
}

templates/php/api.mustache

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,7 @@ use {{invokerPackage}}\RetryStrategy\ClusterHosts;
205205
{{/allParams}}
206206

207207
$resourcePath = '{{{path}}}';
208-
$queryParams = [];
208+
$queryParameters = [];
209209
$httpBody = [];
210210
{{#vendorExtensions}}{{#queryParams}}
211211

@@ -214,15 +214,15 @@ use {{invokerPackage}}\RetryStrategy\ClusterHosts;
214214
{{#style}}
215215
if(is_array(${{paramName}}) && ! in_array('{{paramName}}', RequestOptionsFactory::getAttributesToFormat())) {
216216
foreach(${{paramName}} as $key => $value) {
217-
$queryParams[$key] = $value;
217+
$queryParameters[$key] = $value;
218218
}
219219
}
220220
else {
221-
$queryParams{{^x-is-custom-request}}['{{baseName}}']{{/x-is-custom-request}} = ${{paramName}};
221+
$queryParameters{{^x-is-custom-request}}['{{baseName}}']{{/x-is-custom-request}} = ${{paramName}};
222222
}
223223
{{/style}}
224224
{{^style}}
225-
$queryParams['{{baseName}}'] = ${{paramName}};
225+
$queryParameters['{{baseName}}'] = ${{paramName}};
226226
{{/style}}
227227
}
228228
{{/isExplode}}
@@ -231,7 +231,7 @@ use {{invokerPackage}}\RetryStrategy\ClusterHosts;
231231
${{paramName}} = ObjectSerializer::serializeCollection(${{paramName}}, '{{style}}{{^style}}{{collectionFormat}}{{/style}}', true);
232232
}
233233
if (${{paramName}} !== null) {
234-
$queryParams['{{baseName}}'] = ${{paramName}};
234+
$queryParameters['{{baseName}}'] = ${{paramName}};
235235
}
236236
{{/isExplode}}
237237
{{/queryParams}}{{/vendorExtensions}}
@@ -257,7 +257,7 @@ use {{invokerPackage}}\RetryStrategy\ClusterHosts;
257257
}
258258
{{/bodyParams}}
259259
{{#headerParams}}
260-
$queryParams['{{baseName}}'] = ${{paramName}};
260+
$queryParameters['{{baseName}}'] = ${{paramName}};
261261
{{/headerParams}}
262262
{{#servers.0}}
263263
$operationHosts = [{{#servers}}"{{{url}}}"{{^-last}}, {{/-last}}{{/servers}}];
@@ -267,16 +267,16 @@ use {{invokerPackage}}\RetryStrategy\ClusterHosts;
267267
$operationHost = $operationHosts[$this->hostIndex];
268268

269269
{{/servers.0}}
270-
$requestOptions += $queryParams;
270+
$requestOptions += $queryParameters;
271271

272-
return $this->sendRequest('{{httpMethod}}', $resourcePath, $queryParams, $httpBody, $requestOptions);
272+
return $this->sendRequest('{{httpMethod}}', $resourcePath, $queryParameters, $httpBody, $requestOptions);
273273
}
274274

275275
{{/operation}}
276276

277-
private function sendRequest($method, $resourcePath, $queryParams, $httpBody, $requestOptions)
277+
private function sendRequest($method, $resourcePath, $queryParameters, $httpBody, $requestOptions)
278278
{
279-
$query = \GuzzleHttp\Psr7\Query::build($queryParams);
279+
$query = \GuzzleHttp\Psr7\Query::build($queryParameters);
280280
281281
if($method == 'GET') {
282282
$request = $this->api->read(

tests/output/java/src/test/java/com/algolia/CallEcho.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ private String processResponseBody() {
5050
}
5151
}
5252

53-
private Map<String, String> buildQueryParams() {
53+
private Map<String, String> buildQueryParameters() {
5454
Map<String, String> params = new HashMap<>();
5555
HttpUrl url = request.url();
5656
for (String name : url.queryParameterNames()) {
@@ -73,7 +73,7 @@ public void enqueue(Callback callback) {
7373
body.path = request.url().encodedPath();
7474
body.method = request.method();
7575
body.body = processResponseBody();
76-
body.queryParameters = buildQueryParams();
76+
body.queryParameters = buildQueryParameters();
7777
builder.body(
7878
ResponseBody.create(
7979
JSON.serialize(body),

0 commit comments

Comments
 (0)