Skip to content

Commit bd80c26

Browse files
authored
fix(cts): remove default query parameters APIC-428 (#377)
1 parent 8b52443 commit bd80c26

File tree

131 files changed

+706
-1678
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

131 files changed

+706
-1678
lines changed

generators/src/main/java/com/algolia/codegen/cts/AlgoliaCtsGenerator.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,7 @@ public Map<String, Object> postProcessSupportingFileData(
159159
List<Object> tests = new ArrayList<>();
160160
for (int i = 0; i < op.length; i++) {
161161
Map<String, Object> test = paramsType.buildJSONForRequest(
162+
operationId,
162163
op[i],
163164
entry.getValue(),
164165
i
@@ -174,12 +175,10 @@ public Map<String, Object> postProcessSupportingFileData(
174175

175176
return bundle;
176177
} catch (CTSException e) {
178+
System.out.println(e.getMessage());
177179
if (e.isSkipable()) {
178-
System.out.println(e.getMessage());
179180
System.exit(0);
180181
}
181-
182-
System.out.println(e.getMessage());
183182
System.exit(1);
184183
} catch (Exception e) {
185184
e.printStackTrace();

generators/src/main/java/com/algolia/codegen/cts/ParametersWithDataType.java

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,13 +29,14 @@ public ParametersWithDataType(
2929
}
3030

3131
public Map<String, Object> buildJSONForRequest(
32+
String operationId,
3233
Request req,
3334
CodegenOperation ope,
3435
int testIndex
3536
) throws CTSException, JsonMappingException, JsonProcessingException {
3637
Map<String, Object> test = new HashMap<>();
37-
test.put("method", req.method);
38-
test.put("testName", req.testName == null ? req.method : req.testName);
38+
test.put("method", operationId);
39+
test.put("testName", req.testName == null ? operationId : req.testName);
3940
test.put("testIndex", testIndex);
4041
test.put("request", req.request);
4142

@@ -252,7 +253,7 @@ private void handleModel(
252253
HashMap<String, String> oneOfModel = new HashMap<>();
253254
String typeName = getTypeName(match).replace("<", "").replace(">", "");
254255

255-
oneOfModel.put("classname", Utils.capitalize(baseType));
256+
oneOfModel.put("parentClassName", Utils.capitalize(baseType));
256257

257258
if (typeName.equals("List")) {
258259
CodegenProperty items = match.getItems();
@@ -264,7 +265,7 @@ private void handleModel(
264265
typeName += getTypeName(items);
265266
}
266267

267-
oneOfModel.put("name", typeName);
268+
oneOfModel.put("type", typeName);
268269
testOutput.put("oneOfModel", oneOfModel);
269270

270271
return;

generators/src/main/java/com/algolia/codegen/cts/Request.java

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,18 +12,15 @@
1212
public class Request {
1313

1414
public String testName;
15-
public String method;
1615

1716
public Map<String, Object> parameters;
18-
1917
public RequestProp request;
2018

2119
@Override
2220
public String toString() {
2321
StringBuilder sb = new StringBuilder();
2422
sb.append("class Request {\n");
2523
sb.append(" testName: ").append(testName).append("\n");
26-
sb.append(" method: ").append(method).append("\n");
2724
sb.append(" parameters: ").append(parameters).append("\n");
2825
sb.append(" request: ").append(request).append("\n");
2926
sb.append("}");
@@ -37,19 +34,19 @@ class RequestProp {
3734
public String method;
3835

3936
@JsonDeserialize(using = RawDeserializer.class)
40-
public String data;
37+
public String body;
4138

4239
@JsonDeserialize(using = RawDeserializer.class)
43-
public String searchParams;
40+
public String queryParameters;
4441

4542
@Override
4643
public String toString() {
4744
StringBuilder sb = new StringBuilder();
4845
sb.append("class RequestProp {\n");
4946
sb.append(" path: ").append(path).append("\n");
5047
sb.append(" method: ").append(method).append("\n");
51-
sb.append(" data: ").append(data).append("\n");
52-
sb.append(" searchParams: ").append(searchParams).append("\n");
48+
sb.append(" body: ").append(body).append("\n");
49+
sb.append(" queryParameters: ").append(queryParameters).append("\n");
5350
sb.append("}");
5451
return sb.toString();
5552
}

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

Lines changed: 31 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -194,36 +194,36 @@ public class {{classname}} extends ApiClient {
194194
return res.getData();{{/returnType}}{{^returnType}}this.execute(call).getData();{{/returnType}}
195195
}
196196

197-
{{#optionalParams.0}}
198-
public {{#returnType}}{{{.}}} {{/returnType}}{{^returnType}}void {{/returnType}}{{operationId}}({{#requiredParams}}{{{dataType}}} {{paramName}}{{^-last}}, {{/-last}}{{/requiredParams}}) throws AlgoliaRuntimeException {
199-
{{#returnType}}return {{/returnType}}this.{{operationId}}({{#requiredParams}}{{paramName}}{{^-last}},{{/-last}}{{/requiredParams}}{{#requiredParams.0}},{{/requiredParams.0}}{{#optionalParams}}{{#schema}}{{#defaultValue}}{{{.}}}{{/defaultValue}}{{^defaultValue}}null{{/defaultValue}}{{/schema}}{{^schema}}null{{/schema}}{{^-last}},{{/-last}}{{/optionalParams}});
200-
}
201-
{{/optionalParams.0}}
202-
203-
/**
204-
* (asynchronously)
205-
* {{notes}}{{#allParams}}
206-
* @param {{paramName}} {{{description}}}{{#required}} (required){{/required}}{{^required}} (optional{{^isContainer}}{{#defaultValue}}, default to {{.}}{{/defaultValue}}{{/isContainer}}){{/required}}{{/allParams}}
207-
* @param callback The callback to be executed when the API call finishes
208-
* @return The request call
209-
* @throws AlgoliaRuntimeException If fail to process the API call, e.g. serializing the request body object
210-
{{#isDeprecated}}
211-
* @deprecated
212-
{{/isDeprecated}}
213-
{{#externalDocs}}
214-
* {{&description}}
215-
* @see <a href="{{url}}">{{&summary}} Documentation</a>
216-
{{/externalDocs}}
217-
*/
218-
{{#isDeprecated}}
219-
@Deprecated
220-
{{/isDeprecated}}
221-
public Call {{operationId}}Async({{#allParams}}{{{dataType}}} {{paramName}}, {{/allParams}}final ApiCallback<{{{returnType}}}{{^returnType}}Void{{/returnType}}> callback) throws AlgoliaRuntimeException {
222-
Call call = {{operationId}}ValidateBeforeCall({{#allParams}}{{paramName}}, {{/allParams}}callback);
223-
{{#returnType}}Type returnType = new TypeToken<{{{returnType}}}>(){}.getType();
224-
this.executeAsync(call, returnType, callback);{{/returnType}}{{^returnType}}this.executeAsync(call, callback);{{/returnType}}
225-
return call;
226-
}
227-
{{/operation}}
197+
{{#optionalParams.0}}
198+
public {{#returnType}}{{{.}}} {{/returnType}}{{^returnType}}void {{/returnType}}{{operationId}}({{#requiredParams}}{{{dataType}}} {{paramName}}{{^-last}}, {{/-last}}{{/requiredParams}}) throws AlgoliaRuntimeException {
199+
{{#returnType}}return {{/returnType}}this.{{operationId}}({{#requiredParams}}{{paramName}}{{^-last}},{{/-last}}{{/requiredParams}}{{#requiredParams.0}},{{/requiredParams.0}}{{#optionalParams}}null{{^-last}},{{/-last}}{{/optionalParams}});
200+
}
201+
{{/optionalParams.0}}
202+
203+
/**
204+
* (asynchronously)
205+
* {{notes}}{{#allParams}}
206+
* @param {{paramName}} {{{description}}}{{#required}} (required){{/required}}{{^required}} (optional{{^isContainer}}{{#defaultValue}}, default to {{.}}{{/defaultValue}}{{/isContainer}}){{/required}}{{/allParams}}
207+
* @param callback The callback to be executed when the API call finishes
208+
* @return The request call
209+
* @throws AlgoliaRuntimeException If fail to process the API call, e.g. serializing the request body object
210+
{{#isDeprecated}}
211+
* @deprecated
212+
{{/isDeprecated}}
213+
{{#externalDocs}}
214+
* {{&description}}
215+
* @see <a href="{{url}}">{{&summary}} Documentation</a>
216+
{{/externalDocs}}
217+
*/
218+
{{#isDeprecated}}
219+
@Deprecated
220+
{{/isDeprecated}}
221+
public Call {{operationId}}Async({{#allParams}}{{{dataType}}} {{paramName}}, {{/allParams}}final ApiCallback<{{{returnType}}}{{^returnType}}Void{{/returnType}}> callback) throws AlgoliaRuntimeException {
222+
Call call = {{operationId}}ValidateBeforeCall({{#allParams}}{{paramName}}, {{/allParams}}callback);
223+
{{#returnType}}Type returnType = new TypeToken<{{{returnType}}}>(){}.getType();
224+
this.executeAsync(call, returnType, callback);{{/returnType}}{{^returnType}}this.executeAsync(call, callback);{{/returnType}}
225+
return call;
226+
}
227+
{{/operation}}
228228
}
229229
{{/operations}}

tests/CTS/methods/requests/abtesting/addABTests.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
[
22
{
3-
"method": "addABTests",
43
"testName": "addABTests with minimal parameters",
54
"parameters": {
65
"endAt": "2022-12-31T00:00:00.000Z",
@@ -19,7 +18,7 @@
1918
"request": {
2019
"path": "/2/abtests",
2120
"method": "POST",
22-
"data": {
21+
"body": {
2322
"endAt": "2022-12-31T00:00:00.000Z",
2423
"name": "myABTest",
2524
"variant": [

tests/CTS/methods/requests/abtesting/deleteABTest.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
[
22
{
3-
"method": "deleteABTest",
43
"testName": "deleteABTest",
54
"parameters": {
65
"id": 42

tests/CTS/methods/requests/abtesting/getABTest.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
[
22
{
3-
"method": "getABTest",
43
"testName": "getABTest",
54
"parameters": {
65
"id": 42

tests/CTS/methods/requests/abtesting/listABTests.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
[
22
{
3-
"method": "listABTests",
43
"testName": "listABTests with minimal parameters",
54
"parameters": {
65
"offset": 42,
@@ -9,7 +8,7 @@
98
"request": {
109
"path": "/2/abtests",
1110
"method": "GET",
12-
"searchParams": {
11+
"queryParameters": {
1312
"offset": "42",
1413
"limit": "21"
1514
}

tests/CTS/methods/requests/abtesting/stopABTest.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
[
22
{
3-
"method": "stopABTest",
43
"testName": "stopABTest",
54
"parameters": {
65
"id": 42

tests/CTS/methods/requests/analytics/getAverageClickPosition.json

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,18 @@
11
[
22
{
3-
"method": "getAverageClickPosition",
43
"testName": "get getAverageClickPosition with minimal parameters",
54
"parameters": {
65
"index": "index"
76
},
87
"request": {
98
"path": "/2/clicks/averageClickPosition",
109
"method": "GET",
11-
"searchParams": {
10+
"queryParameters": {
1211
"index": "index"
1312
}
1413
}
1514
},
1615
{
17-
"method": "getAverageClickPosition",
1816
"testName": "get getAverageClickPosition with all parameters",
1917
"parameters": {
2018
"index": "index",
@@ -25,7 +23,7 @@
2523
"request": {
2624
"path": "/2/clicks/averageClickPosition",
2725
"method": "GET",
28-
"searchParams": {
26+
"queryParameters": {
2927
"index": "index",
3028
"startDate": "1999-09-19",
3129
"endDate": "2001-01-01",

tests/CTS/methods/requests/analytics/getClickPositions.json

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,18 @@
11
[
22
{
3-
"method": "getClickPositions",
43
"testName": "get getClickPositions with minimal parameters",
54
"parameters": {
65
"index": "index"
76
},
87
"request": {
98
"path": "/2/clicks/positions",
109
"method": "GET",
11-
"searchParams": {
10+
"queryParameters": {
1211
"index": "index"
1312
}
1413
}
1514
},
1615
{
17-
"method": "getClickPositions",
1816
"testName": "get getClickPositions with all parameters",
1917
"parameters": {
2018
"index": "index",
@@ -25,7 +23,7 @@
2523
"request": {
2624
"path": "/2/clicks/positions",
2725
"method": "GET",
28-
"searchParams": {
26+
"queryParameters": {
2927
"index": "index",
3028
"startDate": "1999-09-19",
3129
"endDate": "2001-01-01",

tests/CTS/methods/requests/analytics/getClickThroughRate.json

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,18 @@
11
[
22
{
3-
"method": "getClickThroughRate",
43
"testName": "get getClickThroughRate with minimal parameters",
54
"parameters": {
65
"index": "index"
76
},
87
"request": {
98
"path": "/2/clicks/clickThroughRate",
109
"method": "GET",
11-
"searchParams": {
10+
"queryParameters": {
1211
"index": "index"
1312
}
1413
}
1514
},
1615
{
17-
"method": "getClickThroughRate",
1816
"testName": "get getClickThroughRate with all parameters",
1917
"parameters": {
2018
"index": "index",
@@ -25,7 +23,7 @@
2523
"request": {
2624
"path": "/2/clicks/clickThroughRate",
2725
"method": "GET",
28-
"searchParams": {
26+
"queryParameters": {
2927
"index": "index",
3028
"startDate": "1999-09-19",
3129
"endDate": "2001-01-01",

tests/CTS/methods/requests/analytics/getConversationRate.json

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,18 @@
11
[
22
{
3-
"method": "getConversationRate",
43
"testName": "get getConversationRate with minimal parameters",
54
"parameters": {
65
"index": "index"
76
},
87
"request": {
98
"path": "/2/conversions/conversionRate",
109
"method": "GET",
11-
"searchParams": {
10+
"queryParameters": {
1211
"index": "index"
1312
}
1413
}
1514
},
1615
{
17-
"method": "getConversationRate",
1816
"testName": "get getConversationRate with all parameters",
1917
"parameters": {
2018
"index": "index",
@@ -25,7 +23,7 @@
2523
"request": {
2624
"path": "/2/conversions/conversionRate",
2725
"method": "GET",
28-
"searchParams": {
26+
"queryParameters": {
2927
"index": "index",
3028
"startDate": "1999-09-19",
3129
"endDate": "2001-01-01",

tests/CTS/methods/requests/analytics/getNoClickRate.json

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,18 @@
11
[
22
{
3-
"method": "getNoClickRate",
43
"testName": "get getNoClickRate with minimal parameters",
54
"parameters": {
65
"index": "index"
76
},
87
"request": {
98
"path": "/2/searches/noClickRate",
109
"method": "GET",
11-
"searchParams": {
10+
"queryParameters": {
1211
"index": "index"
1312
}
1413
}
1514
},
1615
{
17-
"method": "getNoClickRate",
1816
"testName": "get getNoClickRate with all parameters",
1917
"parameters": {
2018
"index": "index",
@@ -25,7 +23,7 @@
2523
"request": {
2624
"path": "/2/searches/noClickRate",
2725
"method": "GET",
28-
"searchParams": {
26+
"queryParameters": {
2927
"index": "index",
3028
"startDate": "1999-09-19",
3129
"endDate": "2001-01-01",

0 commit comments

Comments
 (0)