Skip to content

Commit eb83e3b

Browse files
shortcutsmorganleroimillotpFluf22
authored
docs: lot of guides (#4355)
Co-authored-by: Morgan Leroi <[email protected]> Co-authored-by: Pierre Millot <[email protected]> Co-authored-by: Thomas Raffray <[email protected]>
1 parent 9bfd097 commit eb83e3b

Some content is hidden

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

48 files changed

+2983
-154
lines changed

clients/algoliasearch-client-csharp/algoliasearch/Utils/SearchClientExtensions.cs

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,18 @@ public partial interface ISearchClient
176176
/// <inheritdoc cref="SaveObjectsAsync{T}(string, IEnumerable{T}, RequestOptions, CancellationToken)"/>
177177
List<BatchResponse> SaveObjects<T>(string indexName, IEnumerable<T> objects, bool waitForTasks = false, int batchSize = 1000, RequestOptions options = null, CancellationToken cancellationToken = default) where T : class;
178178

179+
/// <summary>
180+
/// Helper: Saves the given array of objects in the given index. The `chunkedBatch` helper is used under the hood, which creates a `batch` requests with at most 1000 objects in it.
181+
/// </summary>
182+
/// <param name="indexName">The index in which to perform the request.</param>
183+
/// <param name="objects">The list of `objects` to store in the given Algolia `indexName`.</param>
184+
/// <param name="options">Add extra http header or query parameters to Algolia.</param>
185+
/// <param name="cancellationToken">Cancellation Token to cancel the request.</param>
186+
/// <typeparam name="T"></typeparam>
187+
Task<List<BatchResponse>> SaveObjectsAsync<T>(string indexName, IEnumerable<T> objects, RequestOptions options, CancellationToken cancellationToken = default) where T : class;
188+
/// <inheritdoc cref="SaveObjectsAsync{T}(string, IEnumerable{T}, RequestOptions, CancellationToken)"/>
189+
List<BatchResponse> SaveObjects<T>(string indexName, IEnumerable<T> objects, RequestOptions options, CancellationToken cancellationToken = default) where T : class;
190+
179191
/// <summary>
180192
/// Helper: Deletes every records for the given objectIDs. The `chunkedBatch` helper is used under the hood, which creates a `batch` requests with at most 1000 objectIDs in it.
181193
/// </summary>
@@ -598,6 +610,19 @@ public List<BatchResponse> SaveObjects<T>(string indexName, IEnumerable<T> objec
598610
CancellationToken cancellationToken = default) where T : class =>
599611
AsyncHelper.RunSync(() => SaveObjectsAsync(indexName, objects, waitForTasks, batchSize, options, cancellationToken));
600612

613+
/// <inheritdoc/>
614+
public async Task<List<BatchResponse>> SaveObjectsAsync<T>(string indexName, IEnumerable<T> objects,
615+
RequestOptions options,
616+
CancellationToken cancellationToken = default) where T : class
617+
{
618+
return await SaveObjectsAsync(indexName, objects, false, 1000, options, cancellationToken).ConfigureAwait(false);
619+
}
620+
621+
/// <inheritdoc/>
622+
public List<BatchResponse> SaveObjects<T>(string indexName, IEnumerable<T> objects, RequestOptions options,
623+
CancellationToken cancellationToken = default) where T : class =>
624+
AsyncHelper.RunSync(() => SaveObjectsAsync(indexName, objects, options, cancellationToken));
625+
601626
/// <inheritdoc/>
602627
public async Task<List<BatchResponse>> DeleteObjectsAsync(string indexName, IEnumerable<String> objectIDs,
603628
bool waitForTasks = false,

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,7 @@ protected Builder<String, Lambda> addMustacheLambdas() {
100100
lambdas.put("escapeDollar", new EscapeDollarLambda());
101101
lambdas.put("escapeQuotes", new EscapeQuotesLambda());
102102
lambdas.put("escapeSlash", new EscapeSlashLambda());
103+
lambdas.put("escapeJSON", new EscapeJSONLambda());
103104
lambdas.put("replaceBacktick", new ReplaceBacktickLambda());
104105

105106
return lambdas;
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
package com.algolia.codegen.cts.lambda;
2+
3+
import com.samskivert.mustache.Mustache;
4+
import com.samskivert.mustache.Template;
5+
import java.io.IOException;
6+
import java.io.Writer;
7+
8+
public class EscapeJSONLambda implements Mustache.Lambda {
9+
10+
@Override
11+
public void execute(Template.Fragment fragment, Writer writer) throws IOException {
12+
String text = fragment.execute();
13+
writer.write(text.replace("\\", "\\\\").replace("\"", "\\\""));
14+
}
15+
}

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ public class EscapeQuotesLambda implements Mustache.Lambda {
1010
@Override
1111
public void execute(Template.Fragment fragment, Writer writer) throws IOException {
1212
String text = fragment.execute();
13-
writer.write(text.replace("\"", "\\\""));
13+
// replaces all occurrences of " that are not preceded by a backslash with \"
14+
writer.write(text.replaceAll("(?<!\\\\)\"", "\\\\\""));
1415
}
1516
}

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ public class EscapeSlashLambda implements Mustache.Lambda {
1010
@Override
1111
public void execute(Template.Fragment fragment, Writer writer) throws IOException {
1212
String text = fragment.execute();
13-
writer.write(text.replace("\\", "\\\\"));
13+
// replace all backslashes with double backslashes, unless they are followed by a $
14+
writer.write(text.replaceAll("\\\\(?!\\$)", "\\\\\\\\"));
1415
}
1516
}

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

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ private Map<String, Object> traverseParams(
145145
}
146146

147147
testOutput.put("key", paramName);
148-
testOutput.put("useAnonymousKey", !paramName.matches("(.*)_[0-9]$") && depth != 0);
148+
testOutput.put("useAnonymousKey", !paramName.matches("(.*)_[0-9]+$") && depth != 0);
149149
testOutput.put("parent", parent);
150150
testOutput.put("isRoot", "".equals(parent));
151151
testOutput.put("objectName", getObjectNameForLanguage(baseType));
@@ -191,7 +191,7 @@ private Map<String, Object> traverseParams(
191191
private Map<String, Object> traverseParamsWithoutSpec(String paramName, Object param, String parent, int depth) throws CTSException {
192192
Map<String, Object> testOutput = createDefaultOutput();
193193
testOutput.put("key", paramName);
194-
testOutput.put("useAnonymousKey", !paramName.matches("(.*)_[0-9]$") && depth != 0);
194+
testOutput.put("useAnonymousKey", !paramName.matches("(.*)_[0-9]+$") && depth != 0);
195195
testOutput.put("parent", parent);
196196
testOutput.put("isRoot", "".equals(parent));
197197
// try to infer the type
@@ -326,7 +326,7 @@ private void handleModel(
326326
} else {
327327
while (current.getItems() != null) {
328328
current = current.getItems();
329-
typeName += "Of" + getTypeName(current);
329+
typeName += "Of" + Helpers.capitalize(getTypeName(current));
330330
isList = true;
331331
}
332332
}
@@ -492,11 +492,16 @@ private void handlePrimitive(Object param, Map<String, Object> testOutput, IJson
492492
}
493493

494494
private String getTypeName(IJsonSchemaValidationProperties param) {
495+
String typeName = param.getDataType();
495496
if (param instanceof CodegenModel parameter) {
496-
return parameter.classname;
497+
typeName = parameter.classname;
497498
}
498499

499-
return param.getDataType();
500+
if (language.equals("scala") && typeName.equals("List")) {
501+
typeName = "Seq";
502+
}
503+
504+
return typeName;
500505
}
501506

502507
private boolean isString(IJsonSchemaValidationProperties param) {
@@ -592,6 +597,8 @@ private String inferDataType(Object param, CodegenParameter spec, Map<String, Ob
592597
spec.setIsArray(true);
593598
// This is just to find the correct path in `handlePrimitive`, but it's not always the
594599
// real type
600+
// FIXME: this set voluntarily the type to string, which will fail
601+
// We need to infer the real type
595602
CodegenProperty baseItems = new CodegenProperty();
596603
baseItems.dataType = "String";
597604
spec.setItems(baseItems);
@@ -702,6 +709,10 @@ private IJsonSchemaValidationProperties findMatchingOneOf(Object param, CodegenM
702709
return maybeMatch;
703710
}
704711

712+
if (model == null || model.interfaceModels == null) {
713+
return maybeMatch;
714+
}
715+
705716
for (CodegenModel oneOf : model.interfaceModels) {
706717
// Somehow the dataType can be in lower case?
707718
if (oneOf.dataType.equalsIgnoreCase(paramType)) {

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -206,6 +206,8 @@ public void run(Map<String, CodegenModel> models, Map<String, CodegenOperation>
206206
}
207207
}
208208
stepOut.put("match", paramsType.enhanceParameter(step.expected.match));
209+
} else if (!step.type.equals("createClient")) {
210+
stepOut.put("useEchoRequester", false);
209211
}
210212
steps.add(stepOut);
211213
}

playground/javascript/node/search.ts

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,13 @@ console.log('version', apiClientVersion, 'requests', requests);
1717

1818
async function testSearch() {
1919
try {
20-
const res = await client.search({
21-
requests:
22-
[
23-
{ indexName: 'foo', hitsPerPage: 2 }
24-
]
25-
});
26-
27-
// @ts-ignore
28-
console.log(`[OK]`, res.results[0].hits);
20+
const req = await client.setSettings({
21+
indexName: 'theIndexName',
22+
indexSettings: { distinct: true },
23+
})
24+
25+
26+
console.log(`[OK]`, req);
2927
} catch (e: any) {
3028
// Instance of
3129
if (e instanceof ApiError) {

scripts/cts/testServer/algoliaMock.ts

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
import type { Server } from 'http';
2+
3+
import type { Express, Request, Response } from 'express';
4+
5+
import { setupServer } from './index.ts';
6+
7+
// Checks that the client sends a different API key after the first request.
8+
function addRoutes(app: Express): void {
9+
app.post('/1/indexes/:indexName/batch', (req: Request, res: Response) => {
10+
res.json({
11+
taskID: 333,
12+
objectIDs: ['1', '2'],
13+
});
14+
});
15+
app.get('/1/indexes/:indexName/task/:taskID', (req, res) => {
16+
res.json({
17+
status: 'published',
18+
});
19+
});
20+
}
21+
22+
export function algoliaMockServer(): Promise<Server> {
23+
return setupServer('algoliaMock', 6686, addRoutes);
24+
}

scripts/cts/testServer/index.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import { createSpinner } from '../../spinners.ts';
77
import type { CTSType } from '../runCts.ts';
88

99
import { expect } from 'chai';
10+
import { algoliaMockServer } from './algoliaMock.ts';
1011
import { apiKeyServer } from './apiKey.ts';
1112
import { benchmarkServer } from './benchmark.ts';
1213
import { chunkWrapperServer } from './chunkWrapper.ts';
@@ -31,6 +32,7 @@ export async function startTestServer(suites: Record<CTSType, boolean>): Promise
3132
chunkWrapperServer(),
3233
waitForApiKeyServer(),
3334
apiKeyServer(),
35+
algoliaMockServer(),
3436
);
3537
}
3638
if (suites.benchmark) {

templates/csharp/tests/generateInnerParams.mustache

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
{{{value}}}
66
{{/isVerbatim}}
77
{{#isString}}
8-
"{{#lambda.escapeQuotes}}{{#lambda.escapeSlash}}{{{value}}}{{/lambda.escapeSlash}}{{/lambda.escapeQuotes}}"
8+
"{{#lambda.escapeJSON}}{{{value}}}{{/lambda.escapeJSON}}"
99
{{/isString}}
1010
{{#isInteger}}
1111
{{{value}}}

templates/csharp/tests/requests/requests.mustache

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ private readonly {{client}} client;
4646
Assert.Equal("{{{path}}}",req.Path);
4747
Assert.Equal("{{{method}}}",req.Method.ToString());
4848
{{#body}}
49-
JsonAssert.EqualOverrideDefault("{{#lambda.escapeQuotes}}{{{body}}}{{/lambda.escapeQuotes}}", req.Body, new JsonDiffConfig(false));
49+
JsonAssert.EqualOverrideDefault("{{#lambda.escapeJSON}}{{{body}}}{{/lambda.escapeJSON}}", req.Body, new JsonDiffConfig(false));
5050
{{/body}}
5151
{{^body}}
5252
{{#assertNullBody}}

templates/dart/tests/param_value.mustache

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{{#isNull}}empty(){{/isNull}}
22
{{#isVerbatim}}{{{value}}}{{/isVerbatim}}
3-
{{#isString}}"{{#lambda.escapeDollar}}{{{value}}}{{/lambda.escapeDollar}}"{{/isString}}
3+
{{#isString}}"{{#lambda.escapeQuotes}}{{#lambda.escapeDollar}}{{{value}}}{{/lambda.escapeDollar}}{{/lambda.escapeQuotes}}"{{/isString}}
44
{{#isNumber}}{{{value}}}{{/isNumber}}
55
{{#isBoolean}}{{{value}}}{{/isBoolean}}
66
{{#isEnum}}{{{objectName}}}.fromJson("{{value}}"){{/isEnum}}

templates/dart/tests/requests/requests.mustache

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ void main() {
5353
expectParams(request.queryParameters, """{{{.}}}""");
5454
{{/queryParameters}}
5555
{{#body}}
56-
expectBody(request.body, """{{{.}}}""");
56+
expectBody(request.body, """{{#lambda.escapeSlash}}{{{.}}}{{/lambda.escapeSlash}}""");
5757
{{/body}}
5858
{{^body}}
5959
{{#assertNullBody}}

templates/go/api.mustache

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -571,4 +571,4 @@ func (c *APIClient) {{nickname}}({{#hasParams}}r {{#structPrefix}}{{&classname}}
571571

572572
{{#isSearchClient}}
573573
{{> search_helpers}}
574-
{{/isSearchClient}}
574+
{{/isSearchClient}}

templates/go/search_helpers.mustache

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
func CreateIterable[T any](execute func(*T, error) (*T, error), validate func(*T, error) (bool, error), opts ...IterableOption) (*T, error) {
22
conf := config{
3+
headerParams: map[string]string{},
34
maxRetries: -1,
45
timeout: func(count int) time.Duration {
56
return 0 * time.Millisecond
@@ -204,7 +205,7 @@ func (c *APIClient) WaitForApiKey(
204205
operation ApiKeyOperation,
205206
opts ...WaitForApiKeyOption,
206207
) (*GetApiKeyResponse, error) {
207-
conf := config{}
208+
conf := config{headerParams: map[string]string{}}
208209

209210
for _, opt := range opts {
210211
opt.apply(&conf)
@@ -572,6 +573,7 @@ Helper: Replaces object content of all the given objects according to their resp
572573
*/
573574
func (c *APIClient) PartialUpdateObjects(indexName string, objects []map[string]any, opts ...PartialUpdateObjectsOption) ([]BatchResponse, error) {
574575
conf := config{
576+
headerParams: map[string]string{},
575577
createIfNotExists: true,
576578
}
577579

@@ -602,6 +604,7 @@ ChunkedBatch chunks the given `objects` list in subset of 1000 elements max in o
602604
*/
603605
func (c *APIClient) ChunkedBatch(indexName string, objects []map[string]any, action Action, opts ...ChunkedBatchOption) ([]BatchResponse, error) {
604606
conf := config{
607+
headerParams: map[string]string{},
605608
waitForTasks: false,
606609
batchSize: 1000,
607610
}
@@ -653,6 +656,7 @@ func (c *APIClient) ReplaceAllObjects(indexName string, objects []map[string]any
653656
tmpIndexName := fmt.Sprintf("%s_tmp_%d", indexName, time.Now().UnixNano())
654657
655658
conf := config{
659+
headerParams: map[string]string{},
656660
scopes: []ScopeType{SCOPE_TYPE_SETTINGS, SCOPE_TYPE_RULES, SCOPE_TYPE_SYNONYMS},
657661
}
658662

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
{{#isVerbatim}}{{{value}}}{{/isVerbatim}}{{#isHelper}}{{#goFunctionalParam}}{{clientPrefix}}.With{{#lambda.pascalcase}}{{key}}{{/lambda.pascalcase}}({{/goFunctionalParam}}{{/isHelper}}{{#isNull}}{{#inClientTest}}tests.ZeroValue[{{#isNullObject}}*{{clientPrefix}}.{{/isNullObject}}{{objectName}}](){{/inClientTest}}{{^inClientTest}}nil{{/inClientTest}}{{/isNull}}{{#isString}}"{{{value}}}"{{/isString}}{{#isInteger}}{{{value}}}{{/isInteger}}{{#isLong}}{{{value}}}{{/isLong}}{{#isDouble}}{{{value}}}{{/isDouble}}{{#isBoolean}}{{{value}}}{{/isBoolean}}{{#isEnum}}{{clientPrefix}}.{{objectName}}("{{{value}}}"){{/isEnum}}{{#isArray}}
1+
{{#isVerbatim}}{{{value}}}{{/isVerbatim}}{{#isHelper}}{{#goFunctionalParam}}{{clientPrefix}}.With{{#lambda.pascalcase}}{{key}}{{/lambda.pascalcase}}({{/goFunctionalParam}}{{/isHelper}}{{#isNull}}{{#inClientTest}}tests.ZeroValue[{{#isNullObject}}*{{clientPrefix}}.{{/isNullObject}}{{objectName}}](){{/inClientTest}}{{^inClientTest}}nil{{/inClientTest}}{{/isNull}}{{#isString}}"{{#lambda.escapeQuotes}}{{{value}}}{{/lambda.escapeQuotes}}"{{/isString}}{{#isInteger}}{{{value}}}{{/isInteger}}{{#isLong}}{{{value}}}{{/isLong}}{{#isDouble}}{{{value}}}{{/isDouble}}{{#isBoolean}}{{{value}}}{{/isBoolean}}{{#isEnum}}{{clientPrefix}}.{{objectName}}("{{{value}}}"){{/isEnum}}{{#isArray}}
22
{{> tests/arrayType}}{{^value.isEmpty}}{ {{#value}}{{#isObject}}*{{/isObject}}{{#oneOfModel}}{{^isObject}}*{{/isObject}}{{/oneOfModel}}{{> tests/generateParams}},{{/value}} }{{/value.isEmpty}}{{/isArray}}{{#isObject}}
33
{{clientPrefix}}.NewEmpty{{objectName}}(){{#value}}{{#isAdditionalProperty}}.SetAdditionalProperty("{{{key}}}", {{> tests/generateParams}}){{/isAdditionalProperty}}{{^isAdditionalProperty}}.Set{{#lambda.pascalcase}}{{{key}}}{{/lambda.pascalcase}}({{> tests/generateParams}}){{/isAdditionalProperty}}{{/value}}{{/isObject}}{{#isFreeFormObject}}{{#isAnyType}}map[string]any{ {{#value}}{{#entrySet}}"{{{key}}}": "{{{value}}}",{{/entrySet}}{{/value}} }{{/isAnyType}}{{^isAnyType}}{{> tests/mapType}}{ {{#value}}"{{{key}}}": {{#oneOfModel}}{{^isObject}}*{{/isObject}}{{/oneOfModel}}{{#isObject}}*{{/isObject}}{{> tests/generateParams}},{{/value}} }{{/isAnyType}}{{/isFreeFormObject}}{{#isHelper}}{{#goFunctionalParam}}){{/goFunctionalParam}}{{/isHelper}}

templates/go/tests/method.mustache

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,2 @@
11
client.{{#lambda.titlecase}}{{method}}{{/lambda.titlecase}}({{#hasParams}}{{^isHelper}}client.NewApi{{#lambda.titlecase}}{{method}}{{/lambda.titlecase}}Request({{/isHelper}}
2-
{{#parametersWithDataType}}{{#required}}{{> tests/generateParams}},{{/required}}{{/parametersWithDataType}}
3-
{{^isHelper}}){{#parametersWithDataType}}{{^required}}.With{{#lambda.pascalcase}}{{{key}}}{{/lambda.pascalcase}}({{> tests/generateParams}}){{/required}}{{/parametersWithDataType}}{{/isHelper}}{{#isHelper}}{{#parametersWithDataType}}{{^required}}{{> tests/generateParams}},{{/required}}{{/parametersWithDataType}}{{/isHelper}}{{/hasParams}}{{#requestOptions}}{{#hasParams}},{{/hasParams}}
4-
{{#queryParameters.parametersWithDataType}}{{clientPrefix}}.WithQueryParam("{{{key}}}", {{> tests/generateInnerParams}}),{{/queryParameters.parametersWithDataType}}{{#headers.parametersWithDataType}}{{clientPrefix}}.WithHeaderParam("{{{key}}}", {{> tests/generateInnerParams}}),{{/headers.parametersWithDataType}}
5-
{{#timeouts.read}}
6-
{{clientPrefix}}.WithReadTimeout({{.}} * time.Millisecond),
7-
{{/timeouts.read}}
8-
{{#timeouts.write}}
9-
{{clientPrefix}}.WithWriteTimeout({{.}} * time.Millisecond),
10-
{{/timeouts.write}}
11-
{{#timeouts.connect}}
12-
{{clientPrefix}}.WithConnectTimeout({{.}} * time.Millisecond),
13-
{{/timeouts.connect}}
14-
{{/requestOptions}})
2+
{{#parametersWithDataType}}{{#required}}{{> tests/generateParams}},{{/required}}{{/parametersWithDataType}} {{^isHelper}}){{#parametersWithDataType}}{{^required}}.With{{#lambda.pascalcase}}{{{key}}}{{/lambda.pascalcase}}({{> tests/generateParams}}){{#-last}},{{/-last}}{{/required}}{{/parametersWithDataType}}{{/isHelper}}{{#isHelper}}{{#parametersWithDataType}}{{^required}}{{> tests/generateParams}},{{/required}}{{/parametersWithDataType}}{{/isHelper}}{{/hasParams}}{{#requestOptions}}{{#queryParameters.parametersWithDataType}}{{clientPrefix}}.WithQueryParam("{{{key}}}", {{> tests/generateInnerParams}}),{{/queryParameters.parametersWithDataType}}{{#headers.parametersWithDataType}}{{clientPrefix}}.WithHeaderParam("{{{key}}}", {{> tests/generateInnerParams}}),{{/headers.parametersWithDataType}} {{#timeouts.read}} ,{{clientPrefix}}.WithReadTimeout({{.}} * time.Millisecond), {{/timeouts.read}} {{#timeouts.write}} ,{{clientPrefix}}.WithWriteTimeout({{.}} * time.Millisecond), {{/timeouts.write}} {{#timeouts.connect}} ,{{clientPrefix}}.WithConnectTimeout({{.}} * time.Millisecond), {{/timeouts.connect}} {{/requestOptions}})

templates/java/api_helpers.mustache

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1026,7 +1026,7 @@ public <T> ReplaceAllObjectsResponse replaceAllObjects(
10261026
public String generateSecuredApiKey(@Nonnull String parentApiKey, @Nonnull SecuredApiKeyRestrictions restrictions) throws Exception {
10271027
Map<String, String> restrictionsMap = new HashMap<>();
10281028
if (restrictions.getFilters() != null) restrictionsMap.put("filters", StringUtils.paramToString(restrictions.getFilters()));
1029-
if (restrictions.getValidUntil() != 0) restrictionsMap.put("validUntil", StringUtils.paramToString(restrictions.getValidUntil()));
1029+
if (restrictions.getValidUntil() != null && restrictions.getValidUntil() != 0) restrictionsMap.put("validUntil", StringUtils.paramToString(restrictions.getValidUntil()));
10301030
if (restrictions.getRestrictIndices() != null) restrictionsMap.put(
10311031
"restrictIndices",
10321032
StringUtils.paramToString(restrictions.getRestrictIndices())

templates/java/tests/generateInnerParams.mustache

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
{{{value}}}
66
{{/isVerbatim}}
77
{{#isString}}
8-
"{{#lambda.escapeQuotes}}{{#lambda.escapeSlash}}{{{value}}}{{/lambda.escapeSlash}}{{/lambda.escapeQuotes}}"
8+
"{{#lambda.escapeJSON}}{{{value}}}{{/lambda.escapeJSON}}"
99
{{/isString}}
1010
{{#isInteger}}
1111
{{{value}}}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
{{#oneOfModel}}{{^hasWrapper}}{{> tests/generateInnerParams}}{{/hasWrapper}}{{#hasWrapper}}{{{parentClassName}}}.of{{#x-one-of-explicit-name}}{{{type}}}{{/x-one-of-explicit-name}}({{> tests/generateInnerParams}}){{/hasWrapper}}{{/oneOfModel}}{{^oneOfModel}}{{> tests/generateInnerParams}}{{/oneOfModel}}
1+
{{#oneOfModel}}{{^hasWrapper}}{{> tests/generateInnerParams}}{{/hasWrapper}}{{#hasWrapper}}{{{parentClassName}}}.of{{#lambda.pascalcase}}{{#x-one-of-explicit-name}}{{{type}}}{{/x-one-of-explicit-name}}{{/lambda.pascalcase}}({{> tests/generateInnerParams}}){{/hasWrapper}}{{/oneOfModel}}{{^oneOfModel}}{{> tests/generateInnerParams}}{{/oneOfModel}}

templates/java/tests/requests/requests.mustache

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ class {{client}}RequestsTests {
5555
assertEquals("{{{path}}}", req.path);
5656
assertEquals("{{{method}}}", req.method);
5757
{{#body}}
58-
assertDoesNotThrow(() -> JSONAssert.assertEquals("{{#lambda.escapeQuotes}}{{{body}}}{{/lambda.escapeQuotes}}", req.body, JSONCompareMode.STRICT));
58+
assertDoesNotThrow(() -> JSONAssert.assertEquals("{{#lambda.escapeJSON}}{{{body}}}{{/lambda.escapeJSON}}", req.body, JSONCompareMode.STRICT));
5959
{{/body}}
6060
{{^body}}
6161
{{#assertNullBody}}

0 commit comments

Comments
 (0)