Skip to content

Commit 06693ea

Browse files
initial commit
1 parent 3bd6a87 commit 06693ea

File tree

2 files changed

+617
-2
lines changed

2 files changed

+617
-2
lines changed

packages/http-client-csharp/emitter/src/lib/operation-converter.ts

+23-2
Original file line numberDiff line numberDiff line change
@@ -183,8 +183,21 @@ function fromSdkHttpOperationParameter(
183183
const isContentType =
184184
p.kind === "header" && p.serializedName.toLocaleLowerCase() === "content-type";
185185
const parameterType = fromSdkType(p.type, sdkContext, typeMap);
186-
const format = p.kind === "header" || p.kind === "query" ? p.collectionFormat : undefined;
187186
const serializedName = p.kind !== "body" ? p.serializedName : p.name;
187+
let format = p.kind === "header" || p.kind === "query" ? p.collectionFormat : undefined;
188+
let explode = false;
189+
190+
// TO-DO: For record / object types that are exploded, we should consider passing the serialization style to the input parameter
191+
// to determine how the param values should be serialized.
192+
if (parameterType.kind === "array" || parameterType.kind === "dict")
193+
{
194+
if (format === "multi") {
195+
explode = true;
196+
}
197+
else if (isExplodedSdkQueryParameter(p) || isExplodedSdkPathParameter(p)) {
198+
explode = true;
199+
}
200+
}
188201

189202
return {
190203
Name: p.name,
@@ -196,7 +209,7 @@ function fromSdkHttpOperationParameter(
196209
p.name.toLocaleLowerCase() === "apiversion" || p.name.toLocaleLowerCase() === "api-version",
197210
IsContentType: isContentType,
198211
IsEndpoint: false,
199-
Explode: parameterType.kind === "array" && format === "multi" ? true : false,
212+
Explode: explode,
200213
ArraySerializationDelimiter: format ? collectionFormatToDelimMap[format] : undefined,
201214
IsRequired: !p.optional,
202215
Kind: getParameterKind(p, parameterType, rootApiVersions.length > 0),
@@ -418,3 +431,11 @@ function normalizeHeaderName(name: string): string {
418431
return name;
419432
}
420433
}
434+
435+
function isExplodedSdkQueryParameter(p: any): p is SdkQueryParameter {
436+
return (p as SdkQueryParameter).explode === true && (p as SdkQueryParameter).kind === "query";
437+
}
438+
439+
function isExplodedSdkPathParameter(p: any): p is SdkPathParameter {
440+
return (p as SdkPathParameter).explode === true && (p as SdkPathParameter).kind === "path";
441+
}

0 commit comments

Comments
 (0)