Skip to content

Commit e036bcf

Browse files
authored
feat(cts): add tests for search, recommend and dictionaries endpoints (#52)
1 parent 70f041f commit e036bcf

File tree

15 files changed

+899
-45
lines changed

15 files changed

+899
-45
lines changed

clients/algoliasearch-client-java-2/algoliasearch-core/com/algolia/search/SearchApi.java

Lines changed: 8 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1340,7 +1340,7 @@ public okhttp3.Call batchRulesAsync(
13401340
* Build call for browse
13411341
*
13421342
* @param indexName The index in which to perform the request. (required)
1343-
* @param browseRequest (required)
1343+
* @param browseRequest (optional)
13441344
* @param _callback Callback for upload/download progress
13451345
* @return Call to execute
13461346
* @throws ApiException If fail to serialize the request body object
@@ -1413,13 +1413,6 @@ private okhttp3.Call browseValidateBeforeCall(
14131413
);
14141414
}
14151415

1416-
// verify the required parameter 'browseRequest' is set
1417-
if (browseRequest == null) {
1418-
throw new ApiException(
1419-
"Missing the required parameter 'browseRequest' when calling browse(Async)"
1420-
);
1421-
}
1422-
14231416
okhttp3.Call localVarCall = browseCall(indexName, browseRequest, _callback);
14241417
return localVarCall;
14251418
}
@@ -1434,7 +1427,7 @@ private okhttp3.Call browseValidateBeforeCall(
14341427
* has been reached, the cursor field is absent from the response.
14351428
*
14361429
* @param indexName The index in which to perform the request. (required)
1437-
* @param browseRequest (required)
1430+
* @param browseRequest (optional)
14381431
* @return BrowseResponse
14391432
* @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the
14401433
* response body
@@ -1467,7 +1460,7 @@ public BrowseResponse browse(String indexName, BrowseRequest browseRequest)
14671460
* has been reached, the cursor field is absent from the response.
14681461
*
14691462
* @param indexName The index in which to perform the request. (required)
1470-
* @param browseRequest (required)
1463+
* @param browseRequest (optional)
14711464
* @return ApiResponse<BrowseResponse>
14721465
* @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the
14731466
* response body
@@ -1505,7 +1498,7 @@ public ApiResponse<BrowseResponse> browseWithHttpInfo(
15051498
* response.
15061499
*
15071500
* @param indexName The index in which to perform the request. (required)
1508-
* @param browseRequest (required)
1501+
* @param browseRequest (optional)
15091502
* @param _callback The callback to be executed when the API call finishes
15101503
* @return The request call
15111504
* @throws ApiException If fail to process the API call, e.g. serializing the request body object
@@ -7426,7 +7419,7 @@ public okhttp3.Call searchDictionaryEntriesAsync(
74267419
*
74277420
* @param indexName The index in which to perform the request. (required)
74287421
* @param facetName The facet name. (required)
7429-
* @param searchForFacetValuesRequest (required)
7422+
* @param searchForFacetValuesRequest (optional)
74307423
* @param _callback Callback for upload/download progress
74317424
* @return Call to execute
74327425
* @throws ApiException If fail to serialize the request body object
@@ -7512,14 +7505,6 @@ private okhttp3.Call searchForFacetValuesValidateBeforeCall(
75127505
);
75137506
}
75147507

7515-
// verify the required parameter 'searchForFacetValuesRequest' is set
7516-
if (searchForFacetValuesRequest == null) {
7517-
throw new ApiException(
7518-
"Missing the required parameter 'searchForFacetValuesRequest' when calling" +
7519-
" searchForFacetValues(Async)"
7520-
);
7521-
}
7522-
75237508
okhttp3.Call localVarCall = searchForFacetValuesCall(
75247509
indexName,
75257510
facetName,
@@ -7535,7 +7520,7 @@ private okhttp3.Call searchForFacetValuesValidateBeforeCall(
75357520
*
75367521
* @param indexName The index in which to perform the request. (required)
75377522
* @param facetName The facet name. (required)
7538-
* @param searchForFacetValuesRequest (required)
7523+
* @param searchForFacetValuesRequest (optional)
75397524
* @return SearchForFacetValuesResponse
75407525
* @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the
75417526
* response body
@@ -7568,7 +7553,7 @@ public SearchForFacetValuesResponse searchForFacetValues(
75687553
*
75697554
* @param indexName The index in which to perform the request. (required)
75707555
* @param facetName The facet name. (required)
7571-
* @param searchForFacetValuesRequest (required)
7556+
* @param searchForFacetValuesRequest (optional)
75727557
* @return ApiResponse&lt;SearchForFacetValuesResponse&gt;
75737558
* @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the
75747559
* response body
@@ -7605,7 +7590,7 @@ public ApiResponse<SearchForFacetValuesResponse> searchForFacetValuesWithHttpInf
76057590
*
76067591
* @param indexName The index in which to perform the request. (required)
76077592
* @param facetName The facet name. (required)
7608-
* @param searchForFacetValuesRequest (required)
7593+
* @param searchForFacetValuesRequest (optional)
76097594
* @param _callback The callback to be executed when the API call finishes
76107595
* @return The request call
76117596
* @throws ApiException If fail to process the API call, e.g. serializing the request body object

clients/algoliasearch-client-javascript/client-search/src/searchApi.ts

Lines changed: 2 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -443,7 +443,7 @@ export class SearchApi {
443443
*/
444444
browse(
445445
indexName: string,
446-
browseRequest: BrowseRequest
446+
browseRequest?: BrowseRequest
447447
): Promise<BrowseResponse> {
448448
const path = '/1/indexes/{indexName}/browse'.replace(
449449
'{indexName}',
@@ -458,12 +458,6 @@ export class SearchApi {
458458
);
459459
}
460460

461-
if (browseRequest === null || browseRequest === undefined) {
462-
throw new Error(
463-
'Required parameter browseRequest was null or undefined when calling browse.'
464-
);
465-
}
466-
467461
const request: Request = {
468462
method: 'POST',
469463
path,
@@ -1698,7 +1692,7 @@ export class SearchApi {
16981692
searchForFacetValues(
16991693
indexName: string,
17001694
facetName: string,
1701-
searchForFacetValuesRequest: SearchForFacetValuesRequest
1695+
searchForFacetValuesRequest?: SearchForFacetValuesRequest
17021696
): Promise<SearchForFacetValuesResponse> {
17031697
const path = '/1/indexes/{indexName}/facets/{facetName}/query'
17041698
.replace('{indexName}', encodeURIComponent(String(indexName)))
@@ -1718,15 +1712,6 @@ export class SearchApi {
17181712
);
17191713
}
17201714

1721-
if (
1722-
searchForFacetValuesRequest === null ||
1723-
searchForFacetValuesRequest === undefined
1724-
) {
1725-
throw new Error(
1726-
'Required parameter searchForFacetValuesRequest was null or undefined when calling searchForFacetValues.'
1727-
);
1728-
}
1729-
17301715
const request: Request = {
17311716
method: 'POST',
17321717
path,

specs/search/paths/search/browse.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ post:
1212
parameters:
1313
- $ref: '../../../common/parameters.yml#/IndexName'
1414
requestBody:
15-
required: true
1615
content:
1716
application/json:
1817
schema:

specs/search/paths/search/searchForFacetValues.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ post:
1313
schema:
1414
type: string
1515
requestBody:
16-
required: true
1716
content:
1817
application/json:
1918
schema:
Lines changed: 188 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,188 @@
1+
[
2+
{
3+
"method": "getRecommendations",
4+
"testName": "get recommendations with minimal parameters",
5+
"parameters": [
6+
{
7+
"requests": [
8+
{
9+
"indexName": "indexName",
10+
"objectID": "objectID",
11+
"model": "related-products",
12+
"threshold": 42
13+
}
14+
]
15+
}
16+
],
17+
"request": {
18+
"path": "/1/indexes/*/recommendations",
19+
"method": "POST",
20+
"data": {
21+
"requests": [
22+
{
23+
"indexName": "indexName",
24+
"objectID": "objectID",
25+
"model": "related-products",
26+
"threshold": 42
27+
}
28+
]
29+
}
30+
}
31+
},
32+
{
33+
"method": "getRecommendations",
34+
"testName": "get recommendations with all parameters",
35+
"parameters": [
36+
{
37+
"requests": [
38+
{
39+
"indexName": "indexName",
40+
"objectID": "objectID",
41+
"model": "related-products",
42+
"threshold": 42,
43+
"queryParameters": { "facetFilters": ["query"] },
44+
"fallbackParameters": { "facetFilters": ["fallback"] }
45+
}
46+
]
47+
}
48+
],
49+
"request": {
50+
"path": "/1/indexes/*/recommendations",
51+
"method": "POST",
52+
"data": {
53+
"requests": [
54+
{
55+
"indexName": "indexName",
56+
"objectID": "objectID",
57+
"model": "related-products",
58+
"threshold": 42,
59+
"queryParameters": { "facetFilters": ["query"] },
60+
"fallbackParameters": { "facetFilters": ["fallback"] }
61+
}
62+
]
63+
}
64+
}
65+
},
66+
{
67+
"method": "getRecommendations",
68+
"testName": "get multiple recommendations with minimal parameters",
69+
"parameters": [
70+
{
71+
"requests": [
72+
{
73+
"indexName": "indexName1",
74+
"objectID": "objectID1",
75+
"model": "related-products",
76+
"threshold": 21
77+
},
78+
{
79+
"indexName": "indexName2",
80+
"objectID": "objectID2",
81+
"model": "related-products",
82+
"threshold": 21
83+
}
84+
]
85+
}
86+
],
87+
"request": {
88+
"path": "/1/indexes/*/recommendations",
89+
"method": "POST",
90+
"data": {
91+
"requests": [
92+
{
93+
"indexName": "indexName1",
94+
"objectID": "objectID1",
95+
"model": "related-products",
96+
"threshold": 21
97+
},
98+
{
99+
"indexName": "indexName2",
100+
"objectID": "objectID2",
101+
"model": "related-products",
102+
"threshold": 21
103+
}
104+
]
105+
}
106+
}
107+
},
108+
{
109+
"method": "getRecommendations",
110+
"testName": "get multiple recommendations with all parameters",
111+
"parameters": [
112+
{
113+
"requests": [
114+
{
115+
"indexName": "indexName1",
116+
"objectID": "objectID1",
117+
"model": "related-products",
118+
"threshold": 21,
119+
"queryParameters": { "facetFilters": ["query1"] },
120+
"fallbackParameters": { "facetFilters": ["fallback1"] }
121+
},
122+
{
123+
"indexName": "indexName2",
124+
"objectID": "objectID2",
125+
"model": "related-products",
126+
"threshold": 21,
127+
"queryParameters": { "facetFilters": ["query2"] },
128+
"fallbackParameters": { "facetFilters": ["fallback2"] }
129+
}
130+
]
131+
}
132+
],
133+
"request": {
134+
"path": "/1/indexes/*/recommendations",
135+
"method": "POST",
136+
"data": {
137+
"requests": [
138+
{
139+
"indexName": "indexName1",
140+
"objectID": "objectID1",
141+
"model": "related-products",
142+
"threshold": 21,
143+
"queryParameters": { "facetFilters": ["query1"] },
144+
"fallbackParameters": { "facetFilters": ["fallback1"] }
145+
},
146+
{
147+
"indexName": "indexName2",
148+
"objectID": "objectID2",
149+
"model": "related-products",
150+
"threshold": 21,
151+
"queryParameters": { "facetFilters": ["query2"] },
152+
"fallbackParameters": { "facetFilters": ["fallback2"] }
153+
}
154+
]
155+
}
156+
}
157+
},
158+
{
159+
"method": "getRecommendations",
160+
"testName": "get frequently bought together recommendations",
161+
"parameters": [
162+
{
163+
"requests": [
164+
{
165+
"indexName": "indexName1",
166+
"objectID": "objectID1",
167+
"model": "bought-together",
168+
"threshold": 42
169+
}
170+
]
171+
}
172+
],
173+
"request": {
174+
"path": "/1/indexes/*/recommendations",
175+
"method": "POST",
176+
"data": {
177+
"requests": [
178+
{
179+
"indexName": "indexName1",
180+
"objectID": "objectID1",
181+
"model": "bought-together",
182+
"threshold": 42
183+
}
184+
]
185+
}
186+
}
187+
}
188+
]

0 commit comments

Comments
 (0)