Skip to content

Commit edfa906

Browse files
committed
better spec structure and naming
1 parent 92e5499 commit edfa906

File tree

10 files changed

+52
-31
lines changed

10 files changed

+52
-31
lines changed

scripts/generate.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ export async function generate(
5656
spinner.succeed();
5757
}
5858

59-
for (const lang of langs) {
60-
await formatter(lang, getLanguageFolder(lang), verbose);
61-
}
59+
await Promise.all(
60+
langs.map((lang) => formatter(lang, getLanguageFolder(lang), verbose))
61+
);
6262
}

specs/common/schemas/SearchParams.yml

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -232,11 +232,6 @@ page:
232232
x-categories:
233233
- Pagination
234234

235-
cursor:
236-
type: string
237-
description: Cursor indicating the location to resume browsing from. Must match the value returned by the previous call.
238-
example: jMDY3M2MwM2QwMWUxMmQwYWI0ZTN
239-
240235
aroundRadius:
241236
description: Define the maximum radius for a geo search (in meters).
242237
oneOf:
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
browseParams:
2+
oneOf:
3+
- $ref: '../../../common/schemas/SearchParams.yml#/searchParamsString'
4+
- $ref: '#/browseParamsObject'
5+
6+
browseParamsObject:
7+
allOf:
8+
- $ref: '../../../common/schemas/SearchParams.yml#/searchParamsObject'
9+
- $ref: '#/cursor'
10+
11+
cursor:
12+
type: object
13+
additionalProperties: false
14+
properties:
15+
cursor:
16+
type: string
17+
description: Cursor indicating the location to resume browsing from. Must match the value returned by the previous call.
18+
example: jMDY3M2MwM2QwMWUxMmQwYWI0ZTN
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
browseResponse:
2+
allOf:
3+
- $ref: './SearchResponse.yml#/baseSearchResponse'
4+
- $ref: './SearchResponse.yml#/searchHits'
5+
- $ref: './BrowseParams.yml#/cursor'

specs/search/common/schemas/SearchResponse.yml

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,8 @@
1-
SearchResponse:
1+
searchResponse:
22
allOf:
33
- $ref: '#/baseSearchResponse'
44
- $ref: '#/searchHits'
55

6-
browseResponse:
7-
allOf:
8-
- $ref: '#/baseSearchResponse'
9-
- $ref: '#/searchHits'
10-
- $ref: '#/baseBrowseResponse'
11-
12-
baseBrowseResponse:
13-
type: object
14-
additionalProperties: false
15-
properties:
16-
cursor:
17-
$ref: '../../../common/schemas/SearchParams.yml#/cursor'
18-
196
searchHits:
207
type: object
218
additionalProperties: false

specs/search/paths/search/browse.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,14 @@ post:
1515
content:
1616
application/json:
1717
schema:
18-
$ref: '../../../common/schemas/SearchParams.yml#/searchParams'
18+
$ref: '../../common/schemas/BrowseParams.yml#/browseParams'
1919
responses:
2020
'200':
2121
description: OK
2222
content:
2323
application/json:
2424
schema:
25-
$ref: '../../common/schemas/SearchResponse.yml#/browseResponse'
25+
$ref: '../../common/schemas/BrowseResponse.yml#/browseResponse'
2626
'400':
2727
$ref: '../../../common/responses/BadRequest.yml'
2828
'402':

specs/search/paths/search/search.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ post:
3838
results:
3939
type: array
4040
items:
41-
$ref: '../../common/schemas/SearchResponse.yml#/SearchResponse'
41+
$ref: '../../common/schemas/SearchResponse.yml#/searchResponse'
4242
required:
4343
- results
4444
'400':

specs/search/paths/search/searchSingleIndex.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ post:
1919
content:
2020
application/json:
2121
schema:
22-
$ref: '../../common/schemas/SearchResponse.yml#/SearchResponse'
22+
$ref: '../../common/schemas/SearchResponse.yml#/searchResponse'
2323
'400':
2424
$ref: '../../../common/responses/BadRequest.yml'
2525
'402':

templates/javascript/clients/client/api/helpers.mustache

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -113,15 +113,15 @@ waitForApiKey(
113113
* @summary Helper method that iterates on the `browse` method.
114114
* @param browseObjects - The browseObjects object.
115115
* @param browseObjects.indexName - The index in which to perform the request.
116-
* @param browseObjects.searchParams - The `browse` search parameters.
116+
* @param browseObjects.browseParams - The `browse` parameters.
117117
* @param browseObjects.validate - The validator function. It receive the resolved return of the API call. By default, stops when there is no `cursor` in the response.
118118
* @param browseObjects.aggregator - The function that runs right after the API call has been resolved, allows you to do anything with the response before `validate`.
119119
* @param requestOptions - The requestOptions to send along with the query, they will be forwarded to the `browse` method and merged with the transporter requestOptions.
120120
*/
121121
browseObjects<T>(
122122
{
123123
indexName,
124-
searchParams,
124+
browseParams,
125125
...browseObjectsOptions
126126
}: BrowseOptions<BrowseResponse<T>> & BrowseProps,
127127
requestOptions?: RequestOptions
@@ -131,9 +131,9 @@ browseObjects<T>(
131131
return this.browse(
132132
{
133133
indexName,
134-
searchParams: {
134+
browseParams: {
135135
cursor: previousResponse ? previousResponse.cursor : undefined,
136-
...searchParams,
136+
...browseParams,
137137
},
138138
},
139139
requestOptions

tests/CTS/methods/requests/search/browse.json

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
"testName": "browse with search parameters",
1414
"parameters": {
1515
"indexName": "indexName",
16-
"searchParams": {
16+
"browseParams": {
1717
"query": "myQuery",
1818
"facetFilters": [
1919
"tags:algolia"
@@ -30,5 +30,21 @@
3030
]
3131
}
3232
}
33+
},
34+
{
35+
"testName": "browse allow a cursor in parameters",
36+
"parameters": {
37+
"indexName": "indexName",
38+
"browseParams": {
39+
"cursor": "test"
40+
}
41+
},
42+
"request": {
43+
"path": "/1/indexes/indexName/browse",
44+
"method": "POST",
45+
"body": {
46+
"cursor": "test"
47+
}
48+
}
3349
}
3450
]

0 commit comments

Comments
 (0)