Skip to content

Commit

Permalink
a bit simpler
Browse files Browse the repository at this point in the history
  • Loading branch information
shortcuts committed May 10, 2022
1 parent 993f43d commit dbe8058
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 42 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -99,17 +99,14 @@ public Map<String, Object> postProcessOperationsWithModels(
boolean hasQueryParams = ope.queryParams.size() > 0;
boolean hasPathParams = ope.pathParams.size() > 0;

// We don't wrap if there is no mix
if (!hasBodyParams) {
ope.vendorExtensions.put("x-create-wrapping-object", true);
continue;
}

// If there is nothing but path params, we just ensure it's not an array
if (!hasHeaderParams && !hasQueryParams && !hasPathParams) {
// We don't wrap parameters that are arrays, so we explicitely set it
if (!ope.bodyParams.get(0).isArray) {
ope.vendorExtensions.put("x-is-not-body-params-array", true);
// If there is nothing but body params, we just check if it's a single param
if (
hasBodyParams && !hasHeaderParams && !hasQueryParams && !hasPathParams
) {
// At this point the single parameter is already an object, to avoid double wrapping
// we skip it
if (ope.bodyParams.size() == 1 && !ope.bodyParams.get(0).isArray) {
ope.vendorExtensions.put("x-is-single-body-param", true);
continue;
}
}
Expand Down
8 changes: 4 additions & 4 deletions scripts/ci/githubActions/createMatrix.ts
Original file line number Diff line number Diff line change
Expand Up @@ -138,10 +138,10 @@ async function getSpecMatrix(baseBranch: string): Promise<void> {
branch: baseBranch,
path,
});
const baseChanged = await isBaseChanged(
baseBranch,
MATRIX_DEPENDENCIES.common
);
const baseChanged = await isBaseChanged(baseBranch, {
...MATRIX_DEPENDENCIES.common,
...MATRIX_DEPENDENCIES.clients.common,
});

// No changes found, we don't put this job in the matrix
if (specChanges === 0 && !baseChanged) {
Expand Down
52 changes: 25 additions & 27 deletions templates/javascript/api-single.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -113,35 +113,33 @@ export function create{{capitalizedApiName}}(options: CreateClientOptions{{#hasR
* @summary {{&summary}}
{{/summary}}
{{#vendorExtensions}}
{{#allParams.0}}
{{#x-create-wrapping-object}}
* @param {{nickname}} - The {{nickname}} object.
{{#allParams}}
* @param {{nickname}}.{{paramName}} - {{^description}}The {{paramName}} object.{{/description}}{{#description}}{{{description}}}{{/description}}
{{/allParams}}
{{/x-create-wrapping-object}}
{{#x-is-not-body-params-array}}
* @param {{paramName}} - {{^description}}The {{paramName}} object.{{/description}}{{#description}}{{{description}}}{{/description}}
{{/x-is-not-body-params-array}}
{{/allParams.0}}
{{#x-create-wrapping-object}}
* @param {{nickname}} - The {{nickname}} object.
{{#allParams}}
* @param {{nickname}}.{{paramName}} - {{^description}}The {{paramName}} object.{{/description}}{{#description}}{{{description}}}{{/description}}
{{/allParams}}
{{/x-create-wrapping-object}}
{{#x-is-single-body-param}}
{{#bodyParams}}
* @param {{paramName}} - {{^description}}The {{paramName}} object.{{/description}}{{#description}}{{{description}}}{{/description}}
{{/bodyParams}}
{{/x-is-single-body-param}}
{{/vendorExtensions}}
*/
{{nickname}}(
{{#vendorExtensions}}
{{#allParams.0}}
{{#x-create-wrapping-object}}
{
{{#allParams}}
{{paramName}},
{{/allParams}}
}: {{#lambda.titlecase}}{{nickname}}{{/lambda.titlecase}}Props,
{{/x-create-wrapping-object}}
{{#x-is-not-body-params-array}}
{{#bodyParams}}
{{paramName}}: {{{dataType}}},
{{/bodyParams}}
{{/x-is-not-body-params-array}}
{{/allParams.0}}
{{#x-create-wrapping-object}}
{
{{#allParams}}
{{paramName}},
{{/allParams}}
}: {{#lambda.titlecase}}{{nickname}}{{/lambda.titlecase}}Props,
{{/x-create-wrapping-object}}
{{#x-is-single-body-param}}
{{#bodyParams}}
{{paramName}}: {{{dataType}}},
{{/bodyParams}}
{{/x-is-single-body-param}}
{{/vendorExtensions}}
requestOptions?: RequestOptions
) : Promise<{{{returnType}}}> {
Expand Down Expand Up @@ -200,7 +198,7 @@ export function create{{capitalizedApiName}}(options: CreateClientOptions{{#hasR
export type {{capitalizedApiName}} = ReturnType<typeof create{{capitalizedApiName}}>;

{{#operation}}
{{#vendorExtensions}}{{#allParams.0}}
{{#vendorExtensions}}
{{#x-create-wrapping-object}}
export type {{#lambda.titlecase}}{{nickname}}{{/lambda.titlecase}}Props = {
{{#allParams}}
Expand All @@ -213,7 +211,7 @@ export type {{#lambda.titlecase}}{{nickname}}{{/lambda.titlecase}}Props = {
{{/allParams}}
}
{{/x-create-wrapping-object}}
{{/allParams.0}}{{/vendorExtensions}}
{{/vendorExtensions}}

{{/operation}}

Expand Down

0 comments on commit dbe8058

Please sign in to comment.