Skip to content

docs: lot of guides #4355

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 67 commits into from
Jan 22, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
67 commits
Select commit Hold shift + click to select a range
76acd19
docs: lot of guides
shortcuts Jan 13, 2025
b57f0b8
Merge branch 'main' into feat/guide-hackathon
shortcuts Jan 20, 2025
eceac26
feat: distinct
shortcuts Jan 20, 2025
b89aff1
Merge branch 'main' into feat/guide-hackathon
shortcuts Jan 20, 2025
7584460
feat: customRanking, ranking
shortcuts Jan 20, 2025
cb8b5c8
feat: attributesForFaceting, maxFacetHits, maxValuesPerFacet
shortcuts Jan 20, 2025
74bcdd8
feat(doc): add first snippet
morganleroi Jan 20, 2025
4ed3749
feat: searchableAttributes, distinct
shortcuts Jan 20, 2025
5857867
feat: attributesForFaceting
shortcuts Jan 20, 2025
a69ab41
feat: attributesForFaceting and searchableAttributes
shortcuts Jan 20, 2025
d14a88a
feat: customRanking, ranking
shortcuts Jan 20, 2025
712be5b
fix: cts
shortcuts Jan 20, 2025
bc0ae53
fix: cts
shortcuts Jan 20, 2025
8b4d51b
fix: cts
shortcuts Jan 20, 2025
ec5ebe5
fix: cts
shortcuts Jan 20, 2025
890b9a7
feat(doc): add partialUpdateObject snippet
morganleroi Jan 20, 2025
9f9e8be
feat(doc): add partialUpdateObject snippet
morganleroi Jan 20, 2025
1143c25
feat: saveRule
shortcuts Jan 20, 2025
485a0a2
test null
millotp Jan 20, 2025
4abc404
fix
morganleroi Jan 20, 2025
3c9646f
feat: saveRule
shortcuts Jan 20, 2025
cc8bfb0
feat: saveRule
shortcuts Jan 20, 2025
a273b76
feat: saveRule
shortcuts Jan 20, 2025
93147dc
guides: snippets saveObjects/listIndices (#4380)
Fluf22 Jan 20, 2025
e61ee30
fix: query
shortcuts Jan 20, 2025
ea84e67
fix: isSnippet
shortcuts Jan 20, 2025
cfb1875
fix: saveRule
shortcuts Jan 20, 2025
47d919f
chore: format
shortcuts Jan 20, 2025
25ce579
fix: escape and tests
shortcuts Jan 20, 2025
314695d
fix: go TEMPLATE
shortcuts Jan 20, 2025
3626f04
fix: go but don't look at it
shortcuts Jan 20, 2025
da4ebd9
fix: saveRule
shortcuts Jan 20, 2025
98596f1
fix: partialUpdateObject
shortcuts Jan 20, 2025
3ec14d0
fix: hasResponse in client tests
shortcuts Jan 21, 2025
aa31f67
fix: ruby with http info
shortcuts Jan 21, 2025
e4ff110
fix: saveRule
shortcuts Jan 21, 2025
4624874
fix: automaticFacetFilter
shortcuts Jan 21, 2025
c9b7add
fix: java
shortcuts Jan 21, 2025
52f42bd
fix: java
shortcuts Jan 21, 2025
1557d3a
fix: cts
shortcuts Jan 21, 2025
20a3eec
fix: cts
shortcuts Jan 21, 2025
1c07aaa
fix(swift): test template in case of response
Fluf22 Jan 21, 2025
b1347ef
fix java
millotp Jan 21, 2025
e980398
fix go
millotp Jan 21, 2025
119f041
chore: ball in the pied
shortcuts Jan 21, 2025
7130a10
guides: fix saveObjects
Fluf22 Jan 21, 2025
7c52fe1
add test server for saveObjects
millotp Jan 21, 2025
ee12cfb
fix: generate
shortcuts Jan 21, 2025
0006a44
feat: saveRule
shortcuts Jan 21, 2025
e655194
feat: saveRule
shortcuts Jan 21, 2025
2ebcba9
fix: saveRule
shortcuts Jan 21, 2025
942fc3f
fix: saveObjects
shortcuts Jan 21, 2025
fbc24b1
fix: csharp
shortcuts Jan 21, 2025
8df622d
fix: csharp
shortcuts Jan 21, 2025
6d3d2bf
Merge branch 'main' into feat/guide-hackathon
millotp Jan 21, 2025
d7eac22
fix scala
millotp Jan 21, 2025
a48ce57
fix: revert action changes
shortcuts Jan 21, 2025
d12d2ff
chore: missing is snippet and duplicate name
shortcuts Jan 21, 2025
e740584
we control config
millotp Jan 21, 2025
4fe340c
playground
millotp Jan 21, 2025
979ba10
guides: search snippets (#4379)
millotp Jan 22, 2025
6cdd88b
no isSnippet here
millotp Jan 22, 2025
4c8fdc1
Merge branch 'main' into feat/guide-hackathon
shortcuts Jan 22, 2025
8e7b1af
Merge branch 'main' into feat/guide-hackathon
shortcuts Jan 22, 2025
0292b65
feat: saveRules
shortcuts Jan 22, 2025
f4b8151
fix: deprecated options
shortcuts Jan 22, 2025
d2a7c97
fix: cts
shortcuts Jan 22, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,18 @@ public partial interface ISearchClient
/// <inheritdoc cref="SaveObjectsAsync{T}(string, IEnumerable{T}, RequestOptions, CancellationToken)"/>
List<BatchResponse> SaveObjects<T>(string indexName, IEnumerable<T> objects, bool waitForTasks = false, int batchSize = 1000, RequestOptions options = null, CancellationToken cancellationToken = default) where T : class;

/// <summary>
/// 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.
/// </summary>
/// <param name="indexName">The index in which to perform the request.</param>
/// <param name="objects">The list of `objects` to store in the given Algolia `indexName`.</param>
/// <param name="options">Add extra http header or query parameters to Algolia.</param>
/// <param name="cancellationToken">Cancellation Token to cancel the request.</param>
/// <typeparam name="T"></typeparam>
Task<List<BatchResponse>> SaveObjectsAsync<T>(string indexName, IEnumerable<T> objects, RequestOptions options, CancellationToken cancellationToken = default) where T : class;
/// <inheritdoc cref="SaveObjectsAsync{T}(string, IEnumerable{T}, RequestOptions, CancellationToken)"/>
List<BatchResponse> SaveObjects<T>(string indexName, IEnumerable<T> objects, RequestOptions options, CancellationToken cancellationToken = default) where T : class;

/// <summary>
/// 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.
/// </summary>
Expand Down Expand Up @@ -598,6 +610,19 @@ public List<BatchResponse> SaveObjects<T>(string indexName, IEnumerable<T> objec
CancellationToken cancellationToken = default) where T : class =>
AsyncHelper.RunSync(() => SaveObjectsAsync(indexName, objects, waitForTasks, batchSize, options, cancellationToken));

/// <inheritdoc/>
public async Task<List<BatchResponse>> SaveObjectsAsync<T>(string indexName, IEnumerable<T> objects,
RequestOptions options,
CancellationToken cancellationToken = default) where T : class
{
return await SaveObjectsAsync(indexName, objects, false, 1000, options, cancellationToken).ConfigureAwait(false);
}

/// <inheritdoc/>
public List<BatchResponse> SaveObjects<T>(string indexName, IEnumerable<T> objects, RequestOptions options,
CancellationToken cancellationToken = default) where T : class =>
AsyncHelper.RunSync(() => SaveObjectsAsync(indexName, objects, options, cancellationToken));

/// <inheritdoc/>
public async Task<List<BatchResponse>> DeleteObjectsAsync(string indexName, IEnumerable<String> objectIDs,
bool waitForTasks = false,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ protected Builder<String, Lambda> addMustacheLambdas() {
lambdas.put("escapeDollar", new EscapeDollarLambda());
lambdas.put("escapeQuotes", new EscapeQuotesLambda());
lambdas.put("escapeSlash", new EscapeSlashLambda());
lambdas.put("escapeJSON", new EscapeJSONLambda());
lambdas.put("replaceBacktick", new ReplaceBacktickLambda());

return lambdas;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package com.algolia.codegen.cts.lambda;

import com.samskivert.mustache.Mustache;
import com.samskivert.mustache.Template;
import java.io.IOException;
import java.io.Writer;

public class EscapeJSONLambda implements Mustache.Lambda {

@Override
public void execute(Template.Fragment fragment, Writer writer) throws IOException {
String text = fragment.execute();
writer.write(text.replace("\\", "\\\\").replace("\"", "\\\""));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ public class EscapeQuotesLambda implements Mustache.Lambda {
@Override
public void execute(Template.Fragment fragment, Writer writer) throws IOException {
String text = fragment.execute();
writer.write(text.replace("\"", "\\\""));
// replaces all occurrences of " that are not preceded by a backslash with \"
writer.write(text.replaceAll("(?<!\\\\)\"", "\\\\\""));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ public class EscapeSlashLambda implements Mustache.Lambda {
@Override
public void execute(Template.Fragment fragment, Writer writer) throws IOException {
String text = fragment.execute();
writer.write(text.replace("\\", "\\\\"));
// replace all backslashes with double backslashes, unless they are followed by a $
writer.write(text.replaceAll("\\\\(?!\\$)", "\\\\\\\\"));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ private Map<String, Object> traverseParams(
}

testOutput.put("key", paramName);
testOutput.put("useAnonymousKey", !paramName.matches("(.*)_[0-9]$") && depth != 0);
testOutput.put("useAnonymousKey", !paramName.matches("(.*)_[0-9]+$") && depth != 0);
testOutput.put("parent", parent);
testOutput.put("isRoot", "".equals(parent));
testOutput.put("objectName", getObjectNameForLanguage(baseType));
Expand Down Expand Up @@ -191,7 +191,7 @@ private Map<String, Object> traverseParams(
private Map<String, Object> traverseParamsWithoutSpec(String paramName, Object param, String parent, int depth) throws CTSException {
Map<String, Object> testOutput = createDefaultOutput();
testOutput.put("key", paramName);
testOutput.put("useAnonymousKey", !paramName.matches("(.*)_[0-9]$") && depth != 0);
testOutput.put("useAnonymousKey", !paramName.matches("(.*)_[0-9]+$") && depth != 0);
testOutput.put("parent", parent);
testOutput.put("isRoot", "".equals(parent));
// try to infer the type
Expand Down Expand Up @@ -326,7 +326,7 @@ private void handleModel(
} else {
while (current.getItems() != null) {
current = current.getItems();
typeName += "Of" + getTypeName(current);
typeName += "Of" + Helpers.capitalize(getTypeName(current));
isList = true;
}
}
Expand Down Expand Up @@ -492,11 +492,16 @@ private void handlePrimitive(Object param, Map<String, Object> testOutput, IJson
}

private String getTypeName(IJsonSchemaValidationProperties param) {
String typeName = param.getDataType();
if (param instanceof CodegenModel parameter) {
return parameter.classname;
typeName = parameter.classname;
}

return param.getDataType();
if (language.equals("scala") && typeName.equals("List")) {
typeName = "Seq";
}

return typeName;
}

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

if (model == null || model.interfaceModels == null) {
return maybeMatch;
}

for (CodegenModel oneOf : model.interfaceModels) {
// Somehow the dataType can be in lower case?
if (oneOf.dataType.equalsIgnoreCase(paramType)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,8 @@ public void run(Map<String, CodegenModel> models, Map<String, CodegenOperation>
}
}
stepOut.put("match", paramsType.enhanceParameter(step.expected.match));
} else if (!step.type.equals("createClient")) {
stepOut.put("useEchoRequester", false);
}
steps.add(stepOut);
}
Expand Down
16 changes: 7 additions & 9 deletions playground/javascript/node/search.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,13 @@ console.log('version', apiClientVersion, 'requests', requests);

async function testSearch() {
try {
const res = await client.search({
requests:
[
{ indexName: 'foo', hitsPerPage: 2 }
]
});

// @ts-ignore
console.log(`[OK]`, res.results[0].hits);
const req = await client.setSettings({
indexName: 'theIndexName',
indexSettings: { distinct: true },
})


console.log(`[OK]`, req);
} catch (e: any) {
// Instance of
if (e instanceof ApiError) {
Expand Down
24 changes: 24 additions & 0 deletions scripts/cts/testServer/algoliaMock.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import type { Server } from 'http';

import type { Express, Request, Response } from 'express';

import { setupServer } from './index.ts';

// Checks that the client sends a different API key after the first request.
function addRoutes(app: Express): void {
app.post('/1/indexes/:indexName/batch', (req: Request, res: Response) => {
res.json({
taskID: 333,
objectIDs: ['1', '2'],
});
});
app.get('/1/indexes/:indexName/task/:taskID', (req, res) => {
res.json({
status: 'published',
});
});
}

export function algoliaMockServer(): Promise<Server> {
return setupServer('algoliaMock', 6686, addRoutes);
}
2 changes: 2 additions & 0 deletions scripts/cts/testServer/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { createSpinner } from '../../spinners.ts';
import type { CTSType } from '../runCts.ts';

import { expect } from 'chai';
import { algoliaMockServer } from './algoliaMock.ts';
import { apiKeyServer } from './apiKey.ts';
import { benchmarkServer } from './benchmark.ts';
import { chunkWrapperServer } from './chunkWrapper.ts';
Expand All @@ -31,6 +32,7 @@ export async function startTestServer(suites: Record<CTSType, boolean>): Promise
chunkWrapperServer(),
waitForApiKeyServer(),
apiKeyServer(),
algoliaMockServer(),
);
}
if (suites.benchmark) {
Expand Down
2 changes: 1 addition & 1 deletion templates/csharp/tests/generateInnerParams.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
{{{value}}}
{{/isVerbatim}}
{{#isString}}
"{{#lambda.escapeQuotes}}{{#lambda.escapeSlash}}{{{value}}}{{/lambda.escapeSlash}}{{/lambda.escapeQuotes}}"
"{{#lambda.escapeJSON}}{{{value}}}{{/lambda.escapeJSON}}"
{{/isString}}
{{#isInteger}}
{{{value}}}
Expand Down
2 changes: 1 addition & 1 deletion templates/csharp/tests/requests/requests.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ private readonly {{client}} client;
Assert.Equal("{{{path}}}",req.Path);
Assert.Equal("{{{method}}}",req.Method.ToString());
{{#body}}
JsonAssert.EqualOverrideDefault("{{#lambda.escapeQuotes}}{{{body}}}{{/lambda.escapeQuotes}}", req.Body, new JsonDiffConfig(false));
JsonAssert.EqualOverrideDefault("{{#lambda.escapeJSON}}{{{body}}}{{/lambda.escapeJSON}}", req.Body, new JsonDiffConfig(false));
{{/body}}
{{^body}}
{{#assertNullBody}}
Expand Down
2 changes: 1 addition & 1 deletion templates/dart/tests/param_value.mustache
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{{#isNull}}empty(){{/isNull}}
{{#isVerbatim}}{{{value}}}{{/isVerbatim}}
{{#isString}}"{{#lambda.escapeDollar}}{{{value}}}{{/lambda.escapeDollar}}"{{/isString}}
{{#isString}}"{{#lambda.escapeQuotes}}{{#lambda.escapeDollar}}{{{value}}}{{/lambda.escapeDollar}}{{/lambda.escapeQuotes}}"{{/isString}}
{{#isNumber}}{{{value}}}{{/isNumber}}
{{#isBoolean}}{{{value}}}{{/isBoolean}}
{{#isEnum}}{{{objectName}}}.fromJson("{{value}}"){{/isEnum}}
Expand Down
2 changes: 1 addition & 1 deletion templates/dart/tests/requests/requests.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ void main() {
expectParams(request.queryParameters, """{{{.}}}""");
{{/queryParameters}}
{{#body}}
expectBody(request.body, """{{{.}}}""");
expectBody(request.body, """{{#lambda.escapeSlash}}{{{.}}}{{/lambda.escapeSlash}}""");
{{/body}}
{{^body}}
{{#assertNullBody}}
Expand Down
2 changes: 1 addition & 1 deletion templates/go/api.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -571,4 +571,4 @@ func (c *APIClient) {{nickname}}({{#hasParams}}r {{#structPrefix}}{{&classname}}

{{#isSearchClient}}
{{> search_helpers}}
{{/isSearchClient}}
{{/isSearchClient}}
6 changes: 5 additions & 1 deletion templates/go/search_helpers.mustache
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
func CreateIterable[T any](execute func(*T, error) (*T, error), validate func(*T, error) (bool, error), opts ...IterableOption) (*T, error) {
conf := config{
headerParams: map[string]string{},
maxRetries: -1,
timeout: func(count int) time.Duration {
return 0 * time.Millisecond
Expand Down Expand Up @@ -204,7 +205,7 @@ func (c *APIClient) WaitForApiKey(
operation ApiKeyOperation,
opts ...WaitForApiKeyOption,
) (*GetApiKeyResponse, error) {
conf := config{}
conf := config{headerParams: map[string]string{}}

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

Expand Down Expand Up @@ -602,6 +604,7 @@ ChunkedBatch chunks the given `objects` list in subset of 1000 elements max in o
*/
func (c *APIClient) ChunkedBatch(indexName string, objects []map[string]any, action Action, opts ...ChunkedBatchOption) ([]BatchResponse, error) {
conf := config{
headerParams: map[string]string{},
waitForTasks: false,
batchSize: 1000,
}
Expand Down Expand Up @@ -653,6 +656,7 @@ func (c *APIClient) ReplaceAllObjects(indexName string, objects []map[string]any
tmpIndexName := fmt.Sprintf("%s_tmp_%d", indexName, time.Now().UnixNano())

conf := config{
headerParams: map[string]string{},
scopes: []ScopeType{SCOPE_TYPE_SETTINGS, SCOPE_TYPE_RULES, SCOPE_TYPE_SYNONYMS},
}

Expand Down
2 changes: 1 addition & 1 deletion templates/go/tests/generateInnerParams.mustache
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{{#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}}
{{#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}}
{{> tests/arrayType}}{{^value.isEmpty}}{ {{#value}}{{#isObject}}*{{/isObject}}{{#oneOfModel}}{{^isObject}}*{{/isObject}}{{/oneOfModel}}{{> tests/generateParams}},{{/value}} }{{/value.isEmpty}}{{/isArray}}{{#isObject}}
{{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}}
14 changes: 1 addition & 13 deletions templates/go/tests/method.mustache
Original file line number Diff line number Diff line change
@@ -1,14 +1,2 @@
client.{{#lambda.titlecase}}{{method}}{{/lambda.titlecase}}({{#hasParams}}{{^isHelper}}client.NewApi{{#lambda.titlecase}}{{method}}{{/lambda.titlecase}}Request({{/isHelper}}
{{#parametersWithDataType}}{{#required}}{{> tests/generateParams}},{{/required}}{{/parametersWithDataType}}
{{^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}}
{{#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}})
{{#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}})
2 changes: 1 addition & 1 deletion templates/java/api_helpers.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -1026,7 +1026,7 @@ public <T> ReplaceAllObjectsResponse replaceAllObjects(
public String generateSecuredApiKey(@Nonnull String parentApiKey, @Nonnull SecuredApiKeyRestrictions restrictions) throws Exception {
Map<String, String> restrictionsMap = new HashMap<>();
if (restrictions.getFilters() != null) restrictionsMap.put("filters", StringUtils.paramToString(restrictions.getFilters()));
if (restrictions.getValidUntil() != 0) restrictionsMap.put("validUntil", StringUtils.paramToString(restrictions.getValidUntil()));
if (restrictions.getValidUntil() != null && restrictions.getValidUntil() != 0) restrictionsMap.put("validUntil", StringUtils.paramToString(restrictions.getValidUntil()));
if (restrictions.getRestrictIndices() != null) restrictionsMap.put(
"restrictIndices",
StringUtils.paramToString(restrictions.getRestrictIndices())
Expand Down
2 changes: 1 addition & 1 deletion templates/java/tests/generateInnerParams.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
{{{value}}}
{{/isVerbatim}}
{{#isString}}
"{{#lambda.escapeQuotes}}{{#lambda.escapeSlash}}{{{value}}}{{/lambda.escapeSlash}}{{/lambda.escapeQuotes}}"
"{{#lambda.escapeJSON}}{{{value}}}{{/lambda.escapeJSON}}"
{{/isString}}
{{#isInteger}}
{{{value}}}
Expand Down
2 changes: 1 addition & 1 deletion templates/java/tests/generateParams.mustache
Original file line number Diff line number Diff line change
@@ -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}}
{{#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}}
2 changes: 1 addition & 1 deletion templates/java/tests/requests/requests.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ class {{client}}RequestsTests {
assertEquals("{{{path}}}", req.path);
assertEquals("{{{method}}}", req.method);
{{#body}}
assertDoesNotThrow(() -> JSONAssert.assertEquals("{{#lambda.escapeQuotes}}{{{body}}}{{/lambda.escapeQuotes}}", req.body, JSONCompareMode.STRICT));
assertDoesNotThrow(() -> JSONAssert.assertEquals("{{#lambda.escapeJSON}}{{{body}}}{{/lambda.escapeJSON}}", req.body, JSONCompareMode.STRICT));
{{/body}}
{{^body}}
{{#assertNullBody}}
Expand Down
Loading