Skip to content

Commit

Permalink
fix: properly set explode property for params
Browse files Browse the repository at this point in the history
  • Loading branch information
jorgerangel-msft committed Dec 17, 2024
1 parent 71b5c41 commit 075c152
Show file tree
Hide file tree
Showing 3 changed files with 625 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,17 @@ function fromSdkHttpOperationParameter(
const parameterType = fromSdkType(p.type, sdkContext, typeMap);
const format = p.kind === "header" || p.kind === "query" ? p.collectionFormat : undefined;
const serializedName = p.kind !== "body" ? p.serializedName : p.name;
let explode = false;

// TO-DO: In addition to checking if a path parameter is exploded, we should consider capturing the style for
// any path expansion to ensure the parameter values are delimited correctly during serialization.
if (parameterType.kind === "array" || parameterType.kind === "dict") {
if (format === "multi") {
explode = true;
} else if (isExplodedSdkQueryParameter(p) || isExplodedSdkPathParameter(p)) {
explode = true;
}
}

return {
Name: p.name,
Expand All @@ -196,7 +207,7 @@ function fromSdkHttpOperationParameter(
p.name.toLocaleLowerCase() === "apiversion" || p.name.toLocaleLowerCase() === "api-version",
IsContentType: isContentType,
IsEndpoint: false,
Explode: parameterType.kind === "array" && format === "multi" ? true : false,
Explode: explode,
ArraySerializationDelimiter: format ? collectionFormatToDelimMap[format] : undefined,
IsRequired: !p.optional,
Kind: getParameterKind(p, parameterType, rootApiVersions.length > 0),
Expand Down Expand Up @@ -418,3 +429,11 @@ function normalizeHeaderName(name: string): string {
return name;
}
}

function isExplodedSdkQueryParameter(p: any): p is SdkQueryParameter {
return (p as SdkQueryParameter).explode === true && (p as SdkQueryParameter).kind === "query";
}

function isExplodedSdkPathParameter(p: any): p is SdkPathParameter {
return (p as SdkPathParameter).explode === true && (p as SdkPathParameter).kind === "path";
}
Loading

0 comments on commit 075c152

Please sign in to comment.