Skip to content

Commit 8086207

Browse files
committed
a bit simpler
1 parent 993f43d commit 8086207

File tree

3 files changed

+34
-35
lines changed

3 files changed

+34
-35
lines changed

generators/src/main/java/com/algolia/codegen/AlgoliaJavascriptGenerator.java

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -105,11 +105,12 @@ public Map<String, Object> postProcessOperationsWithModels(
105105
continue;
106106
}
107107

108-
// If there is nothing but path params, we just ensure it's not an array
108+
// If there is nothing but body params, we just check if it's a single param
109109
if (!hasHeaderParams && !hasQueryParams && !hasPathParams) {
110-
// We don't wrap parameters that are arrays, so we explicitely set it
111-
if (!ope.bodyParams.get(0).isArray) {
112-
ope.vendorExtensions.put("x-is-not-body-params-array", true);
110+
// At this point the single parameter is already an object, to avoid double wrapping
111+
// we skip it
112+
if (ope.bodyParams.size() == 1 && !ope.bodyParams.get(0).isArray) {
113+
ope.vendorExtensions.put("x-is-single-body-param", true);
113114
continue;
114115
}
115116
}

scripts/ci/githubActions/createMatrix.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -138,10 +138,10 @@ async function getSpecMatrix(baseBranch: string): Promise<void> {
138138
branch: baseBranch,
139139
path,
140140
});
141-
const baseChanged = await isBaseChanged(
142-
baseBranch,
143-
MATRIX_DEPENDENCIES.common
144-
);
141+
const baseChanged = await isBaseChanged(baseBranch, {
142+
...MATRIX_DEPENDENCIES.common,
143+
...MATRIX_DEPENDENCIES.clients.common,
144+
});
145145

146146
// No changes found, we don't put this job in the matrix
147147
if (specChanges === 0 && !baseChanged) {

templates/javascript/api-single.mustache

Lines changed: 25 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -113,35 +113,33 @@ export function create{{capitalizedApiName}}(options: CreateClientOptions{{#hasR
113113
* @summary {{&summary}}
114114
{{/summary}}
115115
{{#vendorExtensions}}
116-
{{#allParams.0}}
117-
{{#x-create-wrapping-object}}
118-
* @param {{nickname}} - The {{nickname}} object.
119-
{{#allParams}}
120-
* @param {{nickname}}.{{paramName}} - {{^description}}The {{paramName}} object.{{/description}}{{#description}}{{{description}}}{{/description}}
121-
{{/allParams}}
122-
{{/x-create-wrapping-object}}
123-
{{#x-is-not-body-params-array}}
124-
* @param {{paramName}} - {{^description}}The {{paramName}} object.{{/description}}{{#description}}{{{description}}}{{/description}}
125-
{{/x-is-not-body-params-array}}
126-
{{/allParams.0}}
116+
{{#x-create-wrapping-object}}
117+
* @param {{nickname}} - The {{nickname}} object.
118+
{{#allParams}}
119+
* @param {{nickname}}.{{paramName}} - {{^description}}The {{paramName}} object.{{/description}}{{#description}}{{{description}}}{{/description}}
120+
{{/allParams}}
121+
{{/x-create-wrapping-object}}
122+
{{#x-is-single-body-param}}
123+
{{#bodyParams}}
124+
* @param {{paramName}} - {{^description}}The {{paramName}} object.{{/description}}{{#description}}{{{description}}}{{/description}}
125+
{{/bodyParams}}
126+
{{/x-is-single-body-param}}
127127
{{/vendorExtensions}}
128128
*/
129129
{{nickname}}(
130130
{{#vendorExtensions}}
131-
{{#allParams.0}}
132-
{{#x-create-wrapping-object}}
133-
{
134-
{{#allParams}}
135-
{{paramName}},
136-
{{/allParams}}
137-
}: {{#lambda.titlecase}}{{nickname}}{{/lambda.titlecase}}Props,
138-
{{/x-create-wrapping-object}}
139-
{{#x-is-not-body-params-array}}
140-
{{#bodyParams}}
141-
{{paramName}}: {{{dataType}}},
142-
{{/bodyParams}}
143-
{{/x-is-not-body-params-array}}
144-
{{/allParams.0}}
131+
{{#x-create-wrapping-object}}
132+
{
133+
{{#allParams}}
134+
{{paramName}},
135+
{{/allParams}}
136+
}: {{#lambda.titlecase}}{{nickname}}{{/lambda.titlecase}}Props,
137+
{{/x-create-wrapping-object}}
138+
{{#x-is-single-body-param}}
139+
{{#bodyParams}}
140+
{{paramName}}: {{{dataType}}},
141+
{{/bodyParams}}
142+
{{/x-is-single-body-param}}
145143
{{/vendorExtensions}}
146144
requestOptions?: RequestOptions
147145
) : Promise<{{{returnType}}}> {
@@ -200,7 +198,7 @@ export function create{{capitalizedApiName}}(options: CreateClientOptions{{#hasR
200198
export type {{capitalizedApiName}} = ReturnType<typeof create{{capitalizedApiName}}>;
201199

202200
{{#operation}}
203-
{{#vendorExtensions}}{{#allParams.0}}
201+
{{#vendorExtensions}}
204202
{{#x-create-wrapping-object}}
205203
export type {{#lambda.titlecase}}{{nickname}}{{/lambda.titlecase}}Props = {
206204
{{#allParams}}
@@ -213,7 +211,7 @@ export type {{#lambda.titlecase}}{{nickname}}{{/lambda.titlecase}}Props = {
213211
{{/allParams}}
214212
}
215213
{{/x-create-wrapping-object}}
216-
{{/allParams.0}}{{/vendorExtensions}}
214+
{{/vendorExtensions}}
217215

218216
{{/operation}}
219217

0 commit comments

Comments
 (0)