Skip to content

Commit ad43bfb

Browse files
shortcutsFluf22
andauthored
guides: add missing snippets to docs (#4391)
Co-authored-by: Thomas Raffray <Fluf22@users.noreply.github.com>
1 parent 1116113 commit ad43bfb

20 files changed

+453
-428
lines changed

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

-3
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
public class Snippet {
1313

1414
public String testName;
15-
public boolean isSnippet;
1615

1716
public String method;
1817
public Map<String, Object> parameters;
@@ -21,7 +20,6 @@ public class Snippet {
2120
public Snippet(String method, String testName, Map<String, Object> parameters) {
2221
this.method = method;
2322
this.testName = testName;
24-
this.isSnippet = true;
2523
this.parameters = parameters;
2624
}
2725

@@ -32,7 +30,6 @@ public String toString() {
3230
StringBuilder sb = new StringBuilder();
3331
sb.append("class Request {\n");
3432
sb.append(" testName: ").append(testName).append("\n");
35-
sb.append(" isSnippet").append(isSnippet).append("\n");
3633
sb.append(" method: ").append(method).append("\n");
3734
sb.append(" parameters: ").append(parameters).append("\n");
3835
sb.append(" requestOptions: ").append(requestOptions).append("\n");

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

+1-6
Original file line numberDiff line numberDiff line change
@@ -101,12 +101,7 @@ public void run(Map<String, CodegenModel> models, Map<String, CodegenOperation>
101101
continue;
102102
}
103103

104-
List<Snippet> ops = Arrays.stream(snippets.get(operationId)).filter(r -> r.isSnippet).toList();
105-
if (ops.size() == 0) {
106-
// default to the first test
107-
ops = List.of(snippets.get(operationId)[0]);
108-
}
109-
104+
List<Snippet> ops = Arrays.stream(snippets.get(operationId)).toList();
110105
List<Map<String, Object>> tests = new ArrayList<>();
111106

112107
for (int i = 0; i < ops.size(); i++) {
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
using Algolia.Search.Clients;
2+
using Algolia.Search.Http;
23
using Algolia.Search.Models.{{clientPrefix}};
+2-1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
import com.algolia.api.{{client}};
2-
import com.algolia.model.{{import}}.*;
2+
import com.algolia.model.{{import}}.*;
3+
import com.algolia.config.*;
+6-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,9 @@
11
import com.algolia.client.api.{{client}}
2+
import com.algolia.client.configuration.*
3+
import com.algolia.client.transport.*
24
{{#isSearchClient}}
35
import com.algolia.client.extensions.*
4-
{{/isSearchClient}}
6+
{{/isSearchClient}}
7+
{{#isCompositionClient}}
8+
import com.algolia.client.model.{{import}}.RequestBody
9+
{{/isCompositionClient}}
+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
(
22
self,
33
{{#allParams}}
4-
{{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}},
4+
{{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}},
55
{{/allParams}}
66
request_options: Optional[Union[dict, RequestOptions]] = None
77
)
+2-1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
from algoliasearch.{{{import}}}.client import {{#lambda.pascalcase}}{{{client}}}{{/lambda.pascalcase}}
2-
from algoliasearch.{{{import}}}.client import {{#lambda.pascalcase}}{{{client}}}Sync{{/lambda.pascalcase}}
2+
from algoliasearch.{{{import}}}.client import {{#lambda.pascalcase}}{{{client}}}Sync{{/lambda.pascalcase}}
3+
from json import loads
+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import algoliasearch.api.{{client}}
2+
import algoliasearch.config.*
23
{{#isSearchClient}}
34
import algoliasearch.extension.SearchClientExtensions
45
{{/isSearchClient}}

tests/CTS/requests/ingestion/listAuthentications.json

+1-3
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,7 @@
1616
"basic",
1717
"algolia"
1818
],
19-
"platform": [
20-
"none"
21-
],
19+
"platform": ["none"],
2220
"sort": "createdAt",
2321
"order": "asc"
2422
},

tests/CTS/requests/search/batch.json

-7
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
[
22
{
33
"testName": "addObject",
4-
"isSnippet": true,
54
"parameters": {
65
"indexName": "<YOUR_INDEX_NAME>",
76
"batchWriteParams": {
@@ -48,7 +47,6 @@
4847
},
4948
{
5049
"testName": "clear",
51-
"isSnippet": true,
5250
"parameters": {
5351
"indexName": "<YOUR_INDEX_NAME>",
5452
"batchWriteParams": {
@@ -79,7 +77,6 @@
7977
},
8078
{
8179
"testName": "delete",
82-
"isSnippet": true,
8380
"parameters": {
8481
"indexName": "<YOUR_INDEX_NAME>",
8582
"batchWriteParams": {
@@ -110,7 +107,6 @@
110107
},
111108
{
112109
"testName": "deleteObject",
113-
"isSnippet": true,
114110
"parameters": {
115111
"indexName": "<YOUR_INDEX_NAME>",
116112
"batchWriteParams": {
@@ -141,7 +137,6 @@
141137
},
142138
{
143139
"testName": "partialUpdateObject",
144-
"isSnippet": true,
145140
"parameters": {
146141
"indexName": "<YOUR_INDEX_NAME>",
147142
"batchWriteParams": {
@@ -172,7 +167,6 @@
172167
},
173168
{
174169
"testName": "partialUpdateObjectNoCreate",
175-
"isSnippet": true,
176170
"parameters": {
177171
"indexName": "<YOUR_INDEX_NAME>",
178172
"batchWriteParams": {
@@ -203,7 +197,6 @@
203197
},
204198
{
205199
"testName": "updateObject",
206-
"isSnippet": true,
207200
"parameters": {
208201
"indexName": "<YOUR_INDEX_NAME>",
209202
"batchWriteParams": {

tests/CTS/requests/search/batchDictionaryEntries.json

-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
[
22
{
33
"testName": "replace",
4-
"isSnippet": true,
54
"parameters": {
65
"dictionaryName": "plurals",
76
"batchDictionaryEntriesParams": {
@@ -56,7 +55,6 @@
5655
},
5756
{
5857
"testName": "delete",
59-
"isSnippet": true,
6058
"parameters": {
6159
"dictionaryName": "plurals",
6260
"batchDictionaryEntriesParams": {
@@ -89,7 +87,6 @@
8987
},
9088
{
9189
"testName": "append",
92-
"isSnippet": true,
9390
"parameters": {
9491
"dictionaryName": "stopwords",
9592
"batchDictionaryEntriesParams": {

tests/CTS/requests/search/listIndices.json

-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
[
22
{
33
"testName": "listIndices with minimal parameters",
4-
"isSnippet": true,
54
"parameters": {},
65
"request": {
76
"path": "/1/indexes",

tests/CTS/requests/search/operationIndex.json

-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
[
22
{
33
"testName": "scopes",
4-
"isSnippet": true,
54
"parameters": {
65
"indexName": "<SOURCE_INDEX_NAME>",
76
"operationIndexParams": {
@@ -28,7 +27,6 @@
2827
},
2928
{
3029
"testName": "copy",
31-
"isSnippet": true,
3230
"parameters": {
3331
"indexName": "<SOURCE_INDEX_NAME>",
3432
"operationIndexParams": {
@@ -47,7 +45,6 @@
4745
},
4846
{
4947
"testName": "move",
50-
"isSnippet": true,
5148
"parameters": {
5249
"indexName": "<SOURCE_INDEX_NAME>",
5350
"operationIndexParams": {

tests/CTS/requests/search/partialUpdateObject.json

-2
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,6 @@
7777
},
7878
{
7979
"testName": "Partial update with a new value for an object attribute",
80-
"isSnippet": true,
8180
"parameters": {
8281
"indexName": "theIndexName",
8382
"objectID": "uniqueID",
@@ -99,7 +98,6 @@
9998
},
10099
{
101100
"testName": "with visible_by filter",
102-
"isSnippet": true,
103101
"parameters": {
104102
"indexName": "theIndexName",
105103
"objectID": "uniqueID",

tests/CTS/requests/search/saveRule.json

-18
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,6 @@
181181
},
182182
{
183183
"testName": "b2b catalog",
184-
"isSnippet": true,
185184
"parameters": {
186185
"indexName": "indexName",
187186
"objectID": "article-rule",
@@ -233,7 +232,6 @@
233232
},
234233
{
235234
"testName": "merchandising and promoting",
236-
"isSnippet": true,
237235
"parameters": {
238236
"indexName": "indexName",
239237
"objectID": "director-rule",
@@ -291,7 +289,6 @@
291289
},
292290
{
293291
"testName": "harry potter",
294-
"isSnippet": true,
295292
"parameters": {
296293
"indexName": "indexName",
297294
"objectID": "harry-potter-rule",
@@ -331,7 +328,6 @@
331328
},
332329
{
333330
"testName": "merchandising empty query",
334-
"isSnippet": true,
335331
"parameters": {
336332
"indexName": "indexName",
337333
"objectID": "clearance-category-filter",
@@ -373,7 +369,6 @@
373369
},
374370
{
375371
"testName": "redirect",
376-
"isSnippet": true,
377372
"parameters": {
378373
"indexName": "indexName",
379374
"objectID": "redirect-help-rule",
@@ -413,7 +408,6 @@
413408
},
414409
{
415410
"testName": "promote some results over others",
416-
"isSnippet": true,
417411
"parameters": {
418412
"indexName": "indexName",
419413
"objectID": "tomato-fruit",
@@ -449,7 +443,6 @@
449443
},
450444
{
451445
"testName": "promote several hits",
452-
"isSnippet": true,
453446
"parameters": {
454447
"indexName": "indexName",
455448
"objectID": "Promote-Apple-Newest",
@@ -491,7 +484,6 @@
491484
},
492485
{
493486
"testName": "promote newest release",
494-
"isSnippet": true,
495487
"parameters": {
496488
"indexName": "indexName",
497489
"objectID": "Promote-iPhone-X",
@@ -533,7 +525,6 @@
533525
},
534526
{
535527
"testName": "promote single item",
536-
"isSnippet": true,
537528
"parameters": {
538529
"indexName": "indexName",
539530
"objectID": "promote-harry-potter-box-set",
@@ -573,7 +564,6 @@
573564
},
574565
{
575566
"testName": "limit search results",
576-
"isSnippet": true,
577567
"parameters": {
578568
"indexName": "indexName",
579569
"objectID": "article-rule",
@@ -621,7 +611,6 @@
621611
},
622612
{
623613
"testName": "query match",
624-
"isSnippet": true,
625614
"parameters": {
626615
"indexName": "indexName",
627616
"objectID": "tagged-brand-rule",
@@ -671,7 +660,6 @@
671660
},
672661
{
673662
"testName": "dynamic filtering",
674-
"isSnippet": true,
675663
"parameters": {
676664
"indexName": "indexName",
677665
"objectID": "color-facets",
@@ -709,7 +697,6 @@
709697
},
710698
{
711699
"testName": "hide hits",
712-
"isSnippet": true,
713700
"parameters": {
714701
"indexName": "indexName",
715702
"objectID": "hide-12345",
@@ -745,7 +732,6 @@
745732
},
746733
{
747734
"testName": "one rule per facet",
748-
"isSnippet": true,
749735
"parameters": {
750736
"indexName": "indexName",
751737
"objectID": "red-color",
@@ -787,7 +773,6 @@
787773
},
788774
{
789775
"testName": "numerical filters",
790-
"isSnippet": true,
791776
"parameters": {
792777
"indexName": "indexName",
793778
"objectID": "cheap",
@@ -829,7 +814,6 @@
829814
},
830815
{
831816
"testName": "negative filters",
832-
"isSnippet": true,
833817
"parameters": {
834818
"indexName": "indexName",
835819
"objectID": "gluten-free-rule",
@@ -881,7 +865,6 @@
881865
},
882866
{
883867
"testName": "positive filters",
884-
"isSnippet": true,
885868
"parameters": {
886869
"indexName": "indexName",
887870
"objectID": "diet-rule",
@@ -933,7 +916,6 @@
933916
},
934917
{
935918
"testName": "conditionless",
936-
"isSnippet": true,
937919
"parameters": {
938920
"indexName": "indexName",
939921
"objectID": "diet-rule",

0 commit comments

Comments
 (0)