Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[http-client-csharp]: Fix explode not being properly set for operation params #5396

Draft
wants to merge 4 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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;
jorgerangel-msft marked this conversation as resolved.
Show resolved Hide resolved
} 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 {
jorgerangel-msft marked this conversation as resolved.
Show resolved Hide resolved
return (p as SdkQueryParameter).explode === true && (p as SdkQueryParameter).kind === "query";
jorgerangel-msft marked this conversation as resolved.
Show resolved Hide resolved
}

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