Skip to content
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

guides: add missing snippets to docs #4391

Merged
merged 15 commits into from
Jan 23, 2025
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
public class Snippet {

public String testName;
public boolean isSnippet;

public String method;
public Map<String, Object> parameters;
Expand All @@ -21,7 +20,6 @@ public class Snippet {
public Snippet(String method, String testName, Map<String, Object> parameters) {
this.method = method;
this.testName = testName;
this.isSnippet = true;
this.parameters = parameters;
}

Expand All @@ -32,7 +30,6 @@ public String toString() {
StringBuilder sb = new StringBuilder();
sb.append("class Request {\n");
sb.append(" testName: ").append(testName).append("\n");
sb.append(" isSnippet").append(isSnippet).append("\n");
sb.append(" method: ").append(method).append("\n");
sb.append(" parameters: ").append(parameters).append("\n");
sb.append(" requestOptions: ").append(requestOptions).append("\n");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,12 +101,7 @@ public void run(Map<String, CodegenModel> models, Map<String, CodegenOperation>
continue;
}

List<Snippet> ops = Arrays.stream(snippets.get(operationId)).filter(r -> r.isSnippet).toList();
if (ops.size() == 0) {
// default to the first test
ops = List.of(snippets.get(operationId)[0]);
}

List<Snippet> ops = Arrays.stream(snippets.get(operationId)).toList();
shortcuts marked this conversation as resolved.
Show resolved Hide resolved
List<Map<String, Object>> tests = new ArrayList<>();

for (int i = 0; i < ops.size(); i++) {
Expand Down
1 change: 1 addition & 0 deletions templates/csharp/snippets/import.mustache
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
using Algolia.Search.Clients;
using Algolia.Search.Http;
using Algolia.Search.Models.{{clientPrefix}};
3 changes: 2 additions & 1 deletion templates/java/snippets/import.mustache
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
import com.algolia.api.{{client}};
import com.algolia.model.{{import}}.*;
import com.algolia.model.{{import}}.*;
import com.algolia.config.*;
7 changes: 6 additions & 1 deletion templates/kotlin/snippets/import.mustache
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
import com.algolia.client.api.{{client}}
import com.algolia.client.configuration.*
import com.algolia.client.transport.*
{{#isSearchClient}}
import com.algolia.client.extensions.*
{{/isSearchClient}}
{{/isSearchClient}}
{{#isCompositionClient}}
import com.algolia.client.model.{{import}}.RequestBody
{{/isCompositionClient}}
2 changes: 1 addition & 1 deletion templates/python/partial_api_args.mustache
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
(
self,
{{#allParams}}
{{paramName}}: {{#isModel}}Union[{{/isModel}}{{#isArray}}{{#items.isModel}}Union[{{/items.isModel}}{{/isArray}}{{#isEnumRef}}Union[{{/isEnumRef}}{{{vendorExtensions.x-py-typing}}}{{#isModel}}, dict[str, Any]]{{/isModel}}{{#isEnumRef}}, str]{{/isEnumRef}}{{#isArray}}{{#items.isModel}}, list[dict[str, Any]]]{{/items.isModel}}{{/isArray}}{{^required}} = None{{/required}},
{{paramName}}: {{#isModel}}Union[{{/isModel}}{{#isArray}}{{#items.isEnumRef}}Union[list[str], {{/items.isEnumRef}}{{#items.isModel}}Union[{{/items.isModel}}{{/isArray}}{{#isEnumRef}}Union[{{/isEnumRef}}{{{vendorExtensions.x-py-typing}}}{{#isModel}}, dict[str, Any]]{{/isModel}}{{#isEnumRef}}, str]{{/isEnumRef}}{{#isArray}}{{#items.isEnumRef}}]{{/items.isEnumRef}}{{#items.isModel}}, {{#isQueryParam}}list[str], {{/isQueryParam}} list[dict[str, Any]]]{{/items.isModel}}{{/isArray}}{{^required}} = None{{/required}},
{{/allParams}}
request_options: Optional[Union[dict, RequestOptions]] = None
)
3 changes: 2 additions & 1 deletion templates/python/snippets/import.mustache
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
from algoliasearch.{{{import}}}.client import {{#lambda.pascalcase}}{{{client}}}{{/lambda.pascalcase}}
from algoliasearch.{{{import}}}.client import {{#lambda.pascalcase}}{{{client}}}Sync{{/lambda.pascalcase}}
from algoliasearch.{{{import}}}.client import {{#lambda.pascalcase}}{{{client}}}Sync{{/lambda.pascalcase}}
from json import loads
1 change: 1 addition & 0 deletions templates/scala/snippets/import.mustache
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import algoliasearch.api.{{client}}
import algoliasearch.config.*
{{#isSearchClient}}
import algoliasearch.extension.SearchClientExtensions
{{/isSearchClient}}
4 changes: 1 addition & 3 deletions tests/CTS/requests/ingestion/listAuthentications.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,7 @@
"basic",
"algolia"
],
"platform": [
"none"
],
"platform": ["none"],
"sort": "createdAt",
"order": "asc"
},
Expand Down
7 changes: 0 additions & 7 deletions tests/CTS/requests/search/batch.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
[
{
"testName": "addObject",
"isSnippet": true,
"parameters": {
"indexName": "<YOUR_INDEX_NAME>",
"batchWriteParams": {
Expand Down Expand Up @@ -48,7 +47,6 @@
},
{
"testName": "clear",
"isSnippet": true,
"parameters": {
"indexName": "<YOUR_INDEX_NAME>",
"batchWriteParams": {
Expand Down Expand Up @@ -79,7 +77,6 @@
},
{
"testName": "delete",
"isSnippet": true,
"parameters": {
"indexName": "<YOUR_INDEX_NAME>",
"batchWriteParams": {
Expand Down Expand Up @@ -110,7 +107,6 @@
},
{
"testName": "deleteObject",
"isSnippet": true,
"parameters": {
"indexName": "<YOUR_INDEX_NAME>",
"batchWriteParams": {
Expand Down Expand Up @@ -141,7 +137,6 @@
},
{
"testName": "partialUpdateObject",
"isSnippet": true,
"parameters": {
"indexName": "<YOUR_INDEX_NAME>",
"batchWriteParams": {
Expand Down Expand Up @@ -172,7 +167,6 @@
},
{
"testName": "partialUpdateObjectNoCreate",
"isSnippet": true,
"parameters": {
"indexName": "<YOUR_INDEX_NAME>",
"batchWriteParams": {
Expand Down Expand Up @@ -203,7 +197,6 @@
},
{
"testName": "updateObject",
"isSnippet": true,
"parameters": {
"indexName": "<YOUR_INDEX_NAME>",
"batchWriteParams": {
Expand Down
3 changes: 0 additions & 3 deletions tests/CTS/requests/search/batchDictionaryEntries.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
[
{
"testName": "replace",
"isSnippet": true,
"parameters": {
"dictionaryName": "plurals",
"batchDictionaryEntriesParams": {
Expand Down Expand Up @@ -56,7 +55,6 @@
},
{
"testName": "delete",
"isSnippet": true,
"parameters": {
"dictionaryName": "plurals",
"batchDictionaryEntriesParams": {
Expand Down Expand Up @@ -89,7 +87,6 @@
},
{
"testName": "append",
"isSnippet": true,
"parameters": {
"dictionaryName": "stopwords",
"batchDictionaryEntriesParams": {
Expand Down
1 change: 0 additions & 1 deletion tests/CTS/requests/search/listIndices.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
[
{
"testName": "listIndices with minimal parameters",
"isSnippet": true,
"parameters": {},
"request": {
"path": "/1/indexes",
Expand Down
3 changes: 0 additions & 3 deletions tests/CTS/requests/search/operationIndex.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
[
{
"testName": "scopes",
"isSnippet": true,
"parameters": {
"indexName": "<SOURCE_INDEX_NAME>",
"operationIndexParams": {
Expand All @@ -28,7 +27,6 @@
},
{
"testName": "copy",
"isSnippet": true,
"parameters": {
"indexName": "<SOURCE_INDEX_NAME>",
"operationIndexParams": {
Expand All @@ -47,7 +45,6 @@
},
{
"testName": "move",
"isSnippet": true,
"parameters": {
"indexName": "<SOURCE_INDEX_NAME>",
"operationIndexParams": {
Expand Down
2 changes: 0 additions & 2 deletions tests/CTS/requests/search/partialUpdateObject.json
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,6 @@
},
{
"testName": "Partial update with a new value for an object attribute",
"isSnippet": true,
"parameters": {
"indexName": "theIndexName",
"objectID": "uniqueID",
Expand All @@ -99,7 +98,6 @@
},
{
"testName": "with visible_by filter",
"isSnippet": true,
"parameters": {
"indexName": "theIndexName",
"objectID": "uniqueID",
Expand Down
18 changes: 0 additions & 18 deletions tests/CTS/requests/search/saveRule.json
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,6 @@
},
{
"testName": "b2b catalog",
"isSnippet": true,
"parameters": {
"indexName": "indexName",
"objectID": "article-rule",
Expand Down Expand Up @@ -233,7 +232,6 @@
},
{
"testName": "merchandising and promoting",
"isSnippet": true,
"parameters": {
"indexName": "indexName",
"objectID": "director-rule",
Expand Down Expand Up @@ -291,7 +289,6 @@
},
{
"testName": "harry potter",
"isSnippet": true,
"parameters": {
"indexName": "indexName",
"objectID": "harry-potter-rule",
Expand Down Expand Up @@ -331,7 +328,6 @@
},
{
"testName": "merchandising empty query",
"isSnippet": true,
"parameters": {
"indexName": "indexName",
"objectID": "clearance-category-filter",
Expand Down Expand Up @@ -373,7 +369,6 @@
},
{
"testName": "redirect",
"isSnippet": true,
"parameters": {
"indexName": "indexName",
"objectID": "redirect-help-rule",
Expand Down Expand Up @@ -413,7 +408,6 @@
},
{
"testName": "promote some results over others",
"isSnippet": true,
"parameters": {
"indexName": "indexName",
"objectID": "tomato-fruit",
Expand Down Expand Up @@ -449,7 +443,6 @@
},
{
"testName": "promote several hits",
"isSnippet": true,
"parameters": {
"indexName": "indexName",
"objectID": "Promote-Apple-Newest",
Expand Down Expand Up @@ -491,7 +484,6 @@
},
{
"testName": "promote newest release",
"isSnippet": true,
"parameters": {
"indexName": "indexName",
"objectID": "Promote-iPhone-X",
Expand Down Expand Up @@ -533,7 +525,6 @@
},
{
"testName": "promote single item",
"isSnippet": true,
"parameters": {
"indexName": "indexName",
"objectID": "promote-harry-potter-box-set",
Expand Down Expand Up @@ -573,7 +564,6 @@
},
{
"testName": "limit search results",
"isSnippet": true,
"parameters": {
"indexName": "indexName",
"objectID": "article-rule",
Expand Down Expand Up @@ -621,7 +611,6 @@
},
{
"testName": "query match",
"isSnippet": true,
"parameters": {
"indexName": "indexName",
"objectID": "tagged-brand-rule",
Expand Down Expand Up @@ -671,7 +660,6 @@
},
{
"testName": "dynamic filtering",
"isSnippet": true,
"parameters": {
"indexName": "indexName",
"objectID": "color-facets",
Expand Down Expand Up @@ -709,7 +697,6 @@
},
{
"testName": "hide hits",
"isSnippet": true,
"parameters": {
"indexName": "indexName",
"objectID": "hide-12345",
Expand Down Expand Up @@ -745,7 +732,6 @@
},
{
"testName": "one rule per facet",
"isSnippet": true,
"parameters": {
"indexName": "indexName",
"objectID": "red-color",
Expand Down Expand Up @@ -787,7 +773,6 @@
},
{
"testName": "numerical filters",
"isSnippet": true,
"parameters": {
"indexName": "indexName",
"objectID": "cheap",
Expand Down Expand Up @@ -829,7 +814,6 @@
},
{
"testName": "negative filters",
"isSnippet": true,
"parameters": {
"indexName": "indexName",
"objectID": "gluten-free-rule",
Expand Down Expand Up @@ -881,7 +865,6 @@
},
{
"testName": "positive filters",
"isSnippet": true,
"parameters": {
"indexName": "indexName",
"objectID": "diet-rule",
Expand Down Expand Up @@ -933,7 +916,6 @@
},
{
"testName": "conditionless",
"isSnippet": true,
"parameters": {
"indexName": "indexName",
"objectID": "diet-rule",
Expand Down
Loading