Skip to content

Commit 442ebf0

Browse files
committed
only for go
1 parent 40793bb commit 442ebf0

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
@@ -39,7 +39,8 @@ public String toString() {
3939
return sb.toString();
4040
}
4141

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

90-
TestsGenerator.setOptionalParameters(ope, context, parameters, isHelper);
91+
TestsGenerator.setOptionalParameters(language, ope, context, parameters, isHelper);
9192

9293
paramsType.enhanceParameters(parameters, context, ope);
9394
} 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
@@ -124,7 +124,7 @@ public void run(Map<String, CodegenModel> models, Map<String, CodegenOperation>
124124
test.put("testName", ops.size() > 1 ? name : "default");
125125
test.put("description", name);
126126
test.put("testIndex", i == 0 ? "" : i);
127-
snippet.addMethodCall(test, paramsType, ope);
127+
snippet.addMethodCall(language, test, paramsType, ope);
128128
addRequestOptions(paramsType, snippet.requestOptions, test);
129129
tests.add(test);
130130
}

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
@@ -164,7 +164,7 @@ public void run(Map<String, CodegenModel> models, Map<String, CodegenOperation>
164164
// default to true because most api calls are asynchronous
165165
testOut.put("isAsyncMethod", (boolean) ope.vendorExtensions.getOrDefault("x-asynchronous-helper", true));
166166

167-
setOptionalParameters(ope, stepOut, step.parameters, isHelper);
167+
setOptionalParameters(language, ope, stepOut, step.parameters, isHelper);
168168
addRequestOptions(paramsType, step.requestOptions, stepOut);
169169

170170
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
@@ -131,11 +131,15 @@ protected void addRequestOptions(ParametersWithDataType paramsType, RequestOptio
131131
}
132132

133133
public static void setOptionalParameters(
134+
String language,
134135
CodegenOperation ope,
135136
Map<String, Object> test,
136137
Map<String, Object> parameters,
137138
boolean isHelper
138139
) {
140+
if (!language.equals("go")) {
141+
return;
142+
}
139143
int bodyPropsOptional = 0;
140144
boolean actuallyHasOptional = false;
141145
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
@@ -171,7 +171,7 @@ public void run(Map<String, CodegenModel> models, Map<String, CodegenOperation>
171171
test.put("hasParams", ope.getHasParams());
172172
test.put("isHelper", isHelper);
173173

174-
setOptionalParameters(ope, test, req.parameters, isHelper);
174+
setOptionalParameters(language, ope, test, req.parameters, isHelper);
175175
addRequestOptions(paramsType, req.requestOptions, test);
176176

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

0 commit comments

Comments
 (0)