Skip to content

Commit

Permalink
initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
jorgerangel-msft committed Dec 17, 2024
1 parent 3bd6a87 commit 06693ea
Show file tree
Hide file tree
Showing 2 changed files with 617 additions and 2 deletions.
25 changes: 23 additions & 2 deletions packages/http-client-csharp/emitter/src/lib/operation-converter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -183,8 +183,21 @@ function fromSdkHttpOperationParameter(
const isContentType =
p.kind === "header" && p.serializedName.toLocaleLowerCase() === "content-type";
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 format = p.kind === "header" || p.kind === "query" ? p.collectionFormat : undefined;

Check warning on line 187 in packages/http-client-csharp/emitter/src/lib/operation-converter.ts

View workflow job for this annotation

GitHub Actions / Lint

'format' is never reassigned. Use 'const' instead
let explode = false;

// TO-DO: For record / object types that are exploded, we should consider passing the serialization style to the input parameter
// to determine how the param values should be serialized.
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 +209,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 +431,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 06693ea

Please sign in to comment.