Skip to content

Commit 8a62493

Browse files
authored
docs: use the correct cURL (#4660)
1 parent ec5ed86 commit 8a62493

File tree

5 files changed

+23
-13
lines changed

5 files changed

+23
-13
lines changed

scripts/specs/format.ts

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -81,9 +81,22 @@ export async function bundleSpecsForDoc(bundledPath: string, clientName: string)
8181

8282
// skip custom path for cURL
8383
if (pathKey !== '/{path}' && specMethod['x-codeSamples']) {
84-
const harRequest = harRequests.find((baseHarRequest) =>
85-
baseHarRequest.url.includes(pathKey.replace('{indexName}', 'ALGOLIA_INDEX_NAME')),
86-
);
84+
const harRequest = harRequests.find((baseHarRequest) => {
85+
// the url also has the query parameters, so we need to check if it ends with the path
86+
// all the variables are also replaced by the example in the spec, so we need to check with a regex.
87+
const urlRegex = new RegExp(
88+
`${pathKey
89+
.replace('{indexName}', 'ALGOLIA_INDEX_NAME')
90+
.replace('*', '\\*')
91+
.replace(/\{.*?\}/g, '.*?')}($|\\?)`,
92+
);
93+
return (
94+
baseHarRequest.url.match(urlRegex) !== null && baseHarRequest.method.toLowerCase() === method.toLowerCase()
95+
);
96+
});
97+
if (!harRequest) {
98+
throw new Error(`Could not find a the correct HAR request for ${method} ${pathKey}`);
99+
}
87100

88101
if (!harRequest?.headers) {
89102
break;

specs/composition-full/paths/search/search.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
post:
22
tags:
3-
- search
3+
- Search
44
operationId: search
55
x-use-read-transporter: true
66
x-cacheable: true

specs/composition-full/paths/search/searchForFacetValues.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
post:
22
tags:
3-
- search
3+
- Search
44
operationId: searchForFacetValues
55
x-use-read-transporter: true
66
x-cacheable: true

specs/composition/spec.yml

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -107,21 +107,18 @@ security:
107107
- appId: []
108108
apiKey: []
109109
tags:
110-
- name: compositions
111-
x-displayName: Compositions
110+
- name: Compositions
112111
description: |
113112
Manage your compositions and composition settings.
114-
- name: rules
115-
x-displayName: Rules
113+
- name: Rules
116114
description: |
117115
Manage your compositions rules.
118-
- name: search
119-
x-displayName: Search
116+
- name: Search
120117
description: Search one composition for matching records or facet values.
121118
x-tagGroups:
122119
- name: Compositions
123120
tags:
124-
- search
121+
- Search
125122
paths:
126123
# ########################
127124
# ### Search Endpoints ###
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
title: indexName
22
type: string
33
description: Name of the Query Suggestions index (case-sensitive).
4-
example: products_query_suggestions
4+
example: ALGOLIA_INDEX_NAME

0 commit comments

Comments
 (0)