Skip to content

Commit 7c3282d

Browse files
committed
only for go
1 parent 582a1f0 commit 7c3282d

File tree

6 files changed

+13
-6
lines changed

6 files changed

+13
-6
lines changed

generators/src/main/java/com/algolia/codegen/cts/lambda/DynamicSnippetLambda.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ public class DynamicSnippetLambda implements Mustache.Lambda {
3232
private final Map<String, CodegenOperation> operations;
3333

3434
private final Map<String, Snippet> snippets;
35+
private final String language;
3536

3637
public DynamicSnippetLambda(
3738
DefaultCodegen generator,
@@ -41,6 +42,7 @@ public DynamicSnippetLambda(
4142
String client
4243
) {
4344
this.operations = operations;
45+
this.language = language;
4446
this.paramsType = new ParametersWithDataType(models, language, client, true);
4547

4648
JsonNode snippetsFile = Helpers.readJsonFile("tests/CTS/guides/" + client + ".json");
@@ -74,7 +76,7 @@ public void execute(Template.Fragment fragment, Writer writer) throws IOExceptio
7476

7577
// set the method attributes
7678
Map<String, Object> context = (Map<String, Object>) fragment.context();
77-
snippet.addMethodCall(context, paramsType, operation);
79+
snippet.addMethodCall(language, context, paramsType, operation);
7880

7981
writer.write(adaptor.compileTemplate(executor, context, "tests/method.mustache"));
8082
}

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,8 @@ public String toString() {
3838
return sb.toString();
3939
}
4040

41-
public void addMethodCall(Map<String, Object> context, ParametersWithDataType paramsType, CodegenOperation ope) throws CTSException {
41+
public void addMethodCall(String language, Map<String, Object> context, ParametersWithDataType paramsType, CodegenOperation ope)
42+
throws CTSException {
4243
// for dynamic snippets, we need to reset the context because the order of generation is random
4344
context.put("method", method);
4445
context.put("returnType", null);
@@ -86,7 +87,7 @@ public void addMethodCall(Map<String, Object> context, ParametersWithDataType pa
8687
}
8788
}
8889

89-
TestsGenerator.setOptionalParameters(ope, context, parameters, isHelper);
90+
TestsGenerator.setOptionalParameters(language, ope, context, parameters, isHelper);
9091

9192
paramsType.enhanceParameters(parameters, context, ope);
9293
} catch (CTSException e) {

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ public void run(Map<String, CodegenModel> models, Map<String, CodegenOperation>
118118
test.put("testName", ops.size() > 1 ? name : "default");
119119
test.put("description", name);
120120
test.put("testIndex", i == 0 ? "" : i);
121-
snippet.addMethodCall(test, paramsType, ope);
121+
snippet.addMethodCall(language, test, paramsType, ope);
122122
addRequestOptions(paramsType, snippet.requestOptions, test);
123123
tests.add(test);
124124
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ public void run(Map<String, CodegenModel> models, Map<String, CodegenOperation>
162162
// default to true because most api calls are asynchronous
163163
testOut.put("isAsyncMethod", (boolean) ope.vendorExtensions.getOrDefault("x-asynchronous-helper", true));
164164

165-
setOptionalParameters(ope, stepOut, step.parameters, isHelper);
165+
setOptionalParameters(language, ope, stepOut, step.parameters, isHelper);
166166
addRequestOptions(paramsType, step.requestOptions, stepOut);
167167

168168
methodCount++;

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,11 +135,15 @@ protected void addRequestOptions(ParametersWithDataType paramsType, RequestOptio
135135
}
136136

137137
public static void setOptionalParameters(
138+
String language,
138139
CodegenOperation ope,
139140
Map<String, Object> test,
140141
Map<String, Object> parameters,
141142
boolean isHelper
142143
) {
144+
if (!language.equals("go")) {
145+
return;
146+
}
143147
int bodyPropsOptional = 0;
144148
boolean actuallyHasOptional = false;
145149
boolean isBodyTooBig = false;

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ public void run(Map<String, CodegenModel> models, Map<String, CodegenOperation>
161161
test.put("hasParams", ope.hasParams);
162162
test.put("isHelper", isHelper);
163163

164-
setOptionalParameters(ope, test, req.parameters, isHelper);
164+
setOptionalParameters(language, ope, test, req.parameters, isHelper);
165165
addRequestOptions(paramsType, req.requestOptions, test);
166166

167167
// Determines whether the endpoint is expected to return a response payload deserialized

0 commit comments

Comments
 (0)