Skip to content

Commit 6a4f7cd

Browse files
committed
no response in snippets
1 parent ddf1377 commit 6a4f7cd

File tree

26 files changed

+51
-51
lines changed

26 files changed

+51
-51
lines changed

generators/src/main/java/com/algolia/codegen/cts/tests/SnippetsGenerator.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -147,11 +147,11 @@ public void run(Map<String, CodegenModel> models, Map<String, CodegenOperation>
147147

148148
// Determines whether the endpoint is expected to return a response payload deserialized
149149
// and therefore a variable to store it into.
150-
test.put("hasResponsePayload", true);
150+
test.put("hasResponse", true);
151151

152152
for (CodegenResponse response : ope.responses) {
153153
if (response.code.equals("204")) {
154-
test.put("hasResponsePayload", false);
154+
test.put("hasResponse", false);
155155
}
156156
}
157157

generators/src/main/java/com/algolia/codegen/cts/tests/TestsClient.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -123,10 +123,10 @@ public void run(Map<String, CodegenModel> models, Map<String, CodegenOperation>
123123

124124
// Determines whether the endpoint is expected to return a response payload
125125
// deserialized and therefore a variable to store it into.
126-
stepOut.put("hasResponsePayload", true);
126+
stepOut.put("hasResponse", true);
127127
for (CodegenResponse response : ope.responses) {
128128
if (response.code.equals("204")) {
129-
stepOut.put("hasResponsePayload", false);
129+
stepOut.put("hasResponse", false);
130130
}
131131
}
132132

generators/src/main/java/com/algolia/codegen/cts/tests/TestsRequest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -168,11 +168,11 @@ public void run(Map<String, CodegenModel> models, Map<String, CodegenOperation>
168168

169169
// Determines whether the endpoint is expected to return a response payload deserialized
170170
// and therefore a variable to store it into.
171-
test.put("hasResponsePayload", true);
171+
test.put("hasResponse", true);
172172

173173
for (CodegenResponse response : ope.responses) {
174174
if (response.code.equals("204")) {
175-
test.put("hasResponsePayload", false);
175+
test.put("hasResponse", false);
176176
}
177177
}
178178

templates/csharp/snippets/method.mustache

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,10 @@ public class Snippet{{client}}
2727
// Initialize the client
2828
var client = new {{client}}(new {{clientPrefix}}Config("YOUR_APP_ID", "YOUR_API_KEY"{{#hasRegionalHost}},"YOUR_APP_ID_REGION"{{/hasRegionalHost}}));
2929

30-
// Call the API
31-
{{#hasResponsePayload}}var response = {{/hasResponsePayload}}{{> tests/method}};
30+
{{#hasResponse}}var response = {{/hasResponse}}{{> tests/method}};
3231
// SEPARATOR<
3332
}
3433

3534
{{/snippets}}
3635
{{/blocksRequests}}
37-
}
36+
}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
{{^useEchoRequester}}{{#hasResponsePayload}}var res = {{/hasResponsePayload}}{{/useEchoRequester}}{{> tests/method}};
1+
{{^useEchoRequester}}{{#hasResponse}}var res = {{/hasResponse}}{{/useEchoRequester}}{{> tests/method}};
22
{{#useEchoRequester}}EchoResponse result = _echo.LastResponse;{{/useEchoRequester}}

templates/dart/snippets/method.mustache

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,8 @@ void snippetFor{{method}}{{testIndex}}() async {
1212
// >SEPARATOR {{method}} {{testName}}
1313
// Initialize the client
1414
final client = {{client}}(appId: 'YOUR_APP_ID', apiKey: 'YOUR_API_KEY'{{#hasRegionalHost}}, region: 'YOUR_APP_ID_REGION'{{/hasRegionalHost}});
15-
16-
// Call the API
17-
final response = await client.{{method}}(
15+
16+
{{#hasResponse}}final response = {{#hasResponse}}{{#isAsync}}await {{/isAsync}}client.{{method}}(
1817
{{#parametersWithDataType}}
1918
{{> tests/request_param}}
2019
{{/parametersWithDataType}}

templates/dart/tests/client/method.mustache

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
try {
2-
{{#hasResponsePayload}}final res = {{/hasResponsePayload}}await client.{{method}}(
2+
{{#hasResponse}}final res = {{/hasResponse}}await client.{{method}}(
33
{{#parametersWithDataType}}
44
{{> tests/request_param}}
55
{{/parametersWithDataType}}

templates/go/snippets/method.mustache

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,18 +23,17 @@ func SnippetFor{{#lambda.titlecase}}{{method}}{{/lambda.titlecase}}Of{{#lambda.p
2323
panic(err)
2424
}
2525

26-
// Call the API
27-
{{#hasResponsePayload}}response, err :={{/hasResponsePayload}}{{^hasResponsePayload}}err ={{/hasResponsePayload}} {{> tests/method}}
26+
{{#hasResponse}}response, err :={{/hasResponse}}{{^hasResponse}}err ={{/hasResponse}} {{> tests/method}}
2827
if err != nil {
2928
// handle the eventual error
3029
panic(err)
3130
}
3231

33-
{{#hasResponsePayload}}
32+
{{#hasResponse}}
3433
// use the model directly
3534
print(response)
36-
{{/hasResponsePayload}}
35+
{{/hasResponse}}
3736
// SEPARATOR<
3837
}
3938
{{/snippets}}
40-
{{/blocksRequests}}
39+
{{/blocksRequests}}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
{{#hasResponsePayload}}res, {{/hasResponsePayload}}err = {{> tests/method}}
1+
{{#hasResponse}}res, {{/hasResponse}}err = {{> tests/method}}

templates/go/tests/requests/requests.mustache

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ func Test{{#lambda.titlecase}}{{clientPrefix}}{{/lambda.titlecase}}_{{#lambda.ti
4040

4141
{{#tests}}
4242
t.Run("{{{testName}}}", func(t *testing.T) {
43-
{{#hasResponsePayload}}_, {{/hasResponsePayload}}err := {{> tests/method}}
43+
{{#hasResponse}}_, {{/hasResponse}}err := {{> tests/method}}
4444
require.NoError(t, err)
4545

4646
{{#request}}

templates/java/snippets/method.mustache

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ class Snippet{{client}} {
1717
// Initialize the client
1818
{{client}} client = new {{client}}("YOUR_APP_ID", "YOUR_API_KEY"{{#hasRegionalHost}}, "YOUR_APP_ID_REGION"{{/hasRegionalHost}});
1919

20-
// Call the API
2120
{{> tests/method}};
2221
// SEPARATOR<
2322
}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
{{^useEchoRequester}}{{#hasResponsePayload}}{{{returnType}}} res = {{/hasResponsePayload}}{{/useEchoRequester}}{{> tests/method}};
1+
{{^useEchoRequester}}{{#hasResponse}}{{{returnType}}} res = {{/hasResponse}}{{/useEchoRequester}}{{> tests/method}};
22
{{#useEchoRequester}}EchoResponse result = echo.getLastResponse();{{/useEchoRequester}}

templates/javascript/snippets/method.mustache

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,11 @@ export {{#isAsync}}async{{/isAsync}} function snippetFor{{#lambda.pascalcase}}{{
1616
// Initialize the client
1717
const client = {{client}}("YOUR_APP_ID", "YOUR_API_KEY", {{#hasRegionalHost}}'YOUR_APP_ID_REGION', {{/hasRegionalHost}});
1818

19-
// Call the API
20-
const response = {{> tests/method}};
21-
19+
{{#hasResponse}}const response = {{/hasResponse}}{{> tests/method}};
20+
{{#hasResponse}}
2221
// use typed response
2322
console.log(response);
23+
{{/hasResponse}}
2424
// SEPARATOR<
2525
}
2626

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
{{#hasResponsePayload}}const result = {{/hasResponsePayload}}{{> tests/method}}{{#useEchoRequester}} as unknown as EchoResponse{{/useEchoRequester}};
1+
{{#hasResponse}}const result = {{/hasResponse}}{{> tests/method}}{{#useEchoRequester}} as unknown as EchoResponse{{/useEchoRequester}};

templates/kotlin/snippets/method.mustache

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,11 @@ class Snippet{{client}} {
1919
// Initialize the client
2020
val client = {{client}}(appId = "YOUR_APP_ID", apiKey = "YOUR_API_KEY"{{#hasRegionalHost}}, region = "YOUR_APP_ID_REGION"{{/hasRegionalHost}})
2121

22-
// Call the API
23-
var response = client.{{> tests/method}}
24-
22+
{{#hasResponse}}var response = {{/hasResponse}}client.{{> tests/method}}
23+
{{#hasResponse}}
2524
// Use the response
2625
println(response)
26+
{{/hasResponse}}
2727
// SEPARATOR<
2828

2929
exitProcess(0)

templates/php/snippets/method.mustache

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,11 @@ class Snippet{{client}}
2323
// Initialize the client
2424
$client = {{client}}::create('<YOUR_APP_ID>', '<YOUR_API_KEY>'{{#hasRegionalHost}}, 'YOUR_APP_ID_REGION'{{/hasRegionalHost}});
2525

26-
// Call the API
27-
$response = {{> tests/method}};
28-
26+
{{#hasResponse}}$response = {{/hasResponse}}{{> tests/method}};
27+
{{#hasResponse}}
2928
// play with the response
3029
var_dump($response);
30+
{{/hasResponse}}
3131
// SEPARATOR<
3232
}
3333

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
{{^useEchoRequester}}{{#hasResponsePayload}}$res = {{/hasResponsePayload}}{{/useEchoRequester}}{{> tests/method}};
1+
{{^useEchoRequester}}{{#hasResponse}}$res = {{/hasResponse}}{{/useEchoRequester}}{{> tests/method}};

templates/python/snippets/method.mustache

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,14 @@ async def snippet_for_{{#lambda.snakecase}}{{method}}{{/lambda.snakecase}}{{test
1616
_client = {{#lambda.pascalcase}}{{{client}}}{{/lambda.pascalcase}}("YOUR_APP_ID", "YOUR_API_KEY"{{#hasRegionalHost}}, "YOUR_APP_ID_REGION"{{/hasRegionalHost}})
1717

1818
# Call the API
19-
response = await _client.{{#lambda.snakecase}}{{method}}{{/lambda.snakecase}}({{#parametersWithDataType}}{{> tests/generateParams}}{{/parametersWithDataType}}{{#hasRequestOptions}} request_options={ {{#requestOptions.headers.parameters}}"headers":loads("""{{{.}}}"""),{{/requestOptions.headers.parameters}}{{#requestOptions.queryParameters.parameters}}"query_parameters":loads("""{{{.}}}"""),{{/requestOptions.queryParameters.parameters}} }{{/hasRequestOptions}})
20-
19+
{{#hasResponse}}response = {{#hasResponse}}{{#isAsync}}await {{/isAsync}}_client.{{#lambda.snakecase}}{{method}}{{/lambda.snakecase}}({{#parametersWithDataType}}{{> tests/generateParams}}{{/parametersWithDataType}}{{#hasRequestOptions}} request_options={ {{#requestOptions.headers.parameters}}"headers":loads("""{{{.}}}"""),{{/requestOptions.headers.parameters}}{{#requestOptions.queryParameters.parameters}}"query_parameters":loads("""{{{.}}}"""),{{/requestOptions.queryParameters.parameters}} }{{/hasRequestOptions}})
20+
{{#hasResponse}}
2121
# use the class directly
2222
print(response)
2323

2424
# print the JSON response
2525
print(response.to_json())
26+
{{/hasResponse}}
2627
# SEPARATOR<
2728

2829
{{/snippets}}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
{{^isError}}{{#hasResponsePayload}}_req = {{/hasResponsePayload}}{{/isError}}{{#isAsync}}await {{/isAsync}}self._client.{{#lambda.snakecase}}{{{method}}}{{/lambda.snakecase}}{{#useEchoRequester}}_with_http_info{{/useEchoRequester}}({{#parametersWithDataType}}{{> tests/generateParams}}{{/parametersWithDataType}}{{#hasRequestOptions}} request_options={ {{#requestOptions.headers.parameters}}"headers":loads("""{{{.}}}"""),{{/requestOptions.headers.parameters}}{{#requestOptions.queryParameters.parameters}}"query_parameters":loads("""{{{.}}}"""),{{/requestOptions.queryParameters.parameters}} }{{/hasRequestOptions}})
1+
{{^isError}}{{#hasResponse}}_req = {{/hasResponse}}{{/isError}}{{#isAsync}}await {{/isAsync}}self._client.{{#lambda.snakecase}}{{{method}}}{{/lambda.snakecase}}{{#useEchoRequester}}_with_http_info{{/useEchoRequester}}({{#parametersWithDataType}}{{> tests/generateParams}}{{/parametersWithDataType}}{{#hasRequestOptions}} request_options={ {{#requestOptions.headers.parameters}}"headers":loads("""{{{.}}}"""),{{/requestOptions.headers.parameters}}{{#requestOptions.queryParameters.parameters}}"query_parameters":loads("""{{{.}}}"""),{{/requestOptions.queryParameters.parameters}} }{{/hasRequestOptions}})

templates/ruby/snippets/method.mustache

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,17 +14,17 @@ def snippet_for_{{#lambda.snakecase}}{{method}}{{/lambda.snakecase}}{{testIndex}
1414
client = Algolia::{{#lambda.pascalcase}}{{{client}}}{{/lambda.pascalcase}}.create('YOUR_APP_ID','YOUR_API_KEY'{{#hasRegionalHost}},'YOUR_APP_ID_REGION'{{/hasRegionalHost}})
1515

1616
# Call the API
17-
{{#hasResponsePayload}}response = {{/hasResponsePayload}}client.{{#lambda.snakecase}}{{method}}{{/lambda.snakecase}}({{#parametersWithDataType}}{{> tests/generateParams}}{{/parametersWithDataType}}{{#hasRequestOptions}}{ {{#requestOptions.headers.parameters}}:header_params => JSON.parse('{{{.}}}', :symbolize_names => true),{{/requestOptions.headers.parameters}}{{#requestOptions.queryParameters.parameters}}:query_params => JSON.parse('{{{.}}}', :symbolize_names => true){{/requestOptions.queryParameters.parameters}} }{{/hasRequestOptions}})
17+
{{#hasResponse}}response = {{/hasResponse}}client.{{#lambda.snakecase}}{{method}}{{/lambda.snakecase}}({{#parametersWithDataType}}{{> tests/generateParams}}{{/parametersWithDataType}}{{#hasRequestOptions}}{ {{#requestOptions.headers.parameters}}:header_params => JSON.parse('{{{.}}}', :symbolize_names => true),{{/requestOptions.headers.parameters}}{{#requestOptions.queryParameters.parameters}}:query_params => JSON.parse('{{{.}}}', :symbolize_names => true){{/requestOptions.queryParameters.parameters}} }{{/hasRequestOptions}})
1818

19-
{{#hasResponsePayload}}
19+
{{#hasResponse}}
2020
# use the class directly
2121
puts response
2222

2323
# print the JSON response
2424
puts response.to_json
25-
{{/hasResponsePayload}}
25+
{{/hasResponse}}
2626
# SEPARATOR<
2727
end
2828

2929
{{/snippets}}
30-
{{/blocksRequests}}
30+
{{/blocksRequests}}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
{{^isError}}{{#hasResponsePayload}}req = {{/hasResponsePayload}}{{/isError}}client.{{#lambda.snakecase}}{{method}}{{/lambda.snakecase}}{{#useEchoRequester}}_with_http_info{{/useEchoRequester}}{{#returnsBoolean}}?{{/returnsBoolean}}({{#parametersWithDataType}}{{> tests/generateParams}}{{/parametersWithDataType}}{{#hasRequestOptions}}{ {{#requestOptions.headers.parameters}}:header_params => JSON.parse('{{{.}}}', :symbolize_names => true),{{/requestOptions.headers.parameters}}{{#requestOptions.queryParameters.parameters}}:query_params => JSON.parse('{{{.}}}', :symbolize_names => true){{/requestOptions.queryParameters.parameters}} }{{/hasRequestOptions}})
1+
{{^isError}}{{#hasResponse}}req = {{/hasResponse}}{{/isError}}client.{{#lambda.snakecase}}{{method}}{{/lambda.snakecase}}{{#useEchoRequester}}_with_http_info{{/useEchoRequester}}{{#returnsBoolean}}?{{/returnsBoolean}}({{#parametersWithDataType}}{{> tests/generateParams}}{{/parametersWithDataType}}{{#hasRequestOptions}}{ {{#requestOptions.headers.parameters}}:header_params => JSON.parse('{{{.}}}', :symbolize_names => true),{{/requestOptions.headers.parameters}}{{#requestOptions.queryParameters.parameters}}:query_params => JSON.parse('{{{.}}}', :symbolize_names => true){{/requestOptions.queryParameters.parameters}} }{{/hasRequestOptions}})

templates/scala/snippets/method.mustache

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,11 @@ class Snippet{{client}} {
3131
// Initialize the client
3232
val client = {{client}}(appId = "YOUR_APP_ID", apiKey = "YOUR_API_KEY"{{#hasRegionalHost}}, region = {{#fallbackToAliasHost}}Option({{/fallbackToAliasHost}}"YOUR_APP_ID_REGION"{{#fallbackToAliasHost}}){{/fallbackToAliasHost}}{{/hasRegionalHost}})
3333

34-
// Call the API
35-
val response = {{> tests/method}}
36-
34+
{{#hasResponse}}val response = {{/hasResponse}}{{> tests/method}}
35+
{{#hasResponse}}
3736
// Use the response
3837
val value = Await.result(response, Duration(100, "sec"))
38+
{{/hasResponse}}
3939
// SEPARATOR<
4040
}
4141

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
{{^useEchoRequester}}{{#hasResponsePayload}}var res = {{/hasResponsePayload}}{{#isAsync}}Await.result{{/isAsync}}{{/useEchoRequester}}{{#isAsync}}{{#useEchoRequester}}Await.ready{{/useEchoRequester}}({{/isAsync}}
1+
{{^useEchoRequester}}{{#hasResponse}}var res = {{/hasResponse}}{{#isAsync}}Await.result{{/isAsync}}{{/useEchoRequester}}{{#isAsync}}{{#useEchoRequester}}Await.ready{{/useEchoRequester}}({{/isAsync}}
22
{{> tests/method}}{{#isAsync}},
33
Duration.Inf
44
){{/isAsync}}

templates/swift/snippets/method.mustache

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,7 @@ final class {{client}}Snippet {
1616
// Initialize the client
1717
let client = try {{client}}(appID: "YOUR_APP_ID", apiKey: "YOUR_API_KEY"{{#hasRegionalHost}}, region: .{{defaultRegion}}{{/hasRegionalHost}})
1818

19-
// Call the API
20-
let response{{#isGeneric}}: {{{returnType}}}<Hit>{{/isGeneric}} = try {{#isAsync}}await {{/isAsync}}client.{{method}}({{#hasParams}}{{#parametersWithDataType}}{{> tests/generateParams }}{{^-last}}, {{/-last}}{{/parametersWithDataType}}{{/hasParams}}{{#hasRequestOptions}}, requestOptions: RequestOptions({{#requestOptions.headers}}
19+
{{#hasResponse}}let response{{#isGeneric}}: {{{returnType}}}<Hit>{{/isGeneric}} = {{/hasResponse}}try {{#isAsync}}await {{/isAsync}}client.{{method}}({{#hasParams}}{{#parametersWithDataType}}{{> tests/generateParams }}{{^-last}}, {{/-last}}{{/parametersWithDataType}}{{/hasParams}}{{#hasRequestOptions}}, requestOptions: RequestOptions({{#requestOptions.headers}}
2120
headers: [{{#parametersWithDataType}}"{{key}}": {{> tests/paramValue }}{{^-last}}, {{/-last}}{{/parametersWithDataType}}]{{/requestOptions.headers}}
2221
{{#requestOptions.headers}}{{#requestOptions.queryParameters}},{{/requestOptions.queryParameters}}{{/requestOptions.headers}}{{#requestOptions.queryParameters}}
2322
queryParameters: [{{#parametersWithDataType}}"{{key}}": {{> tests/paramValue }}{{^-last}}, {{/-last}}{{/parametersWithDataType}}]{{/requestOptions.queryParameters}}

templates/swift/tests/client/method.mustache

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
{{#hasResponsePayload}}let response{{#isGeneric}}: Response<{{{returnType}}}<Hit>>{{/isGeneric}} = {{/hasResponsePayload}}{{> tests/method}}
1+
{{#hasResponse}}let response{{#isGeneric}}: Response<{{{returnType}}}<Hit>>{{/isGeneric}} = {{/hasResponse}}{{> tests/method}}
22
{{^isHelper}}
33
{{^isBenchmark}}
44
let responseBodyData = try XCTUnwrap(response.bodyData)

templates/swift/tests/client/tests.mustache

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
{{/autoCreateClient}}
1212

1313
{{#steps}}
14-
{{^isCreateClient}} do { {{/isCreateClient}}
1514
{{#times}}
1615
for i in 1...{{.}} {
1716
{{/times}}
@@ -25,6 +24,9 @@
2524
}
2625
{{/isError}}
2726
{{^isError}}
27+
{{#shouldScope}}
28+
do {
29+
{{/shouldScope}}
2830
{{#dynamicTemplate}}{{/dynamicTemplate}}
2931
{{#testUserAgent}}
3032

@@ -65,11 +67,13 @@
6567
XCTAssertEqual(comparableJSON, responseBodyJSON);
6668
{{/isHelper}}
6769
{{/testResponse}}
70+
{{#shouldScope}}
71+
}
72+
{{/shouldScope}}
6873
{{/isError}}
6974
{{#times}}
7075
}
7176
{{/times}}
72-
{{^isCreateClient}} } {{/isCreateClient}}
7377
{{/steps}}
7478
}
7579
{{/tests}}

0 commit comments

Comments
 (0)