Skip to content

Commit

Permalink
Support void type body (#3620)
Browse files Browse the repository at this point in the history
Migrate Azure/autorest.csharp#4809

Co-authored-by: Dapeng Zhang <dapzhang@microsoft.com>
  • Loading branch information
pshao25 and ArcturusZhang authored Jun 20, 2024
1 parent f566053 commit fc137a9
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions packages/http-client-csharp/emitter/src/lib/operation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import {
ModelProperty,
Namespace,
Operation,
Type,
getDeprecated,
getDoc,
getSummary,
Expand Down Expand Up @@ -78,9 +79,9 @@ export function loadOperation(
parameters.push(loadOperationParameter(sdkContext, p));
}

if (typespecParameters.body?.parameter) {
if (typespecParameters.body?.parameter && !isVoidType(typespecParameters.body.type)) {
parameters.push(loadBodyParameter(sdkContext, typespecParameters.body?.parameter));
} else if (typespecParameters.body?.type) {
} else if (typespecParameters.body?.type && !isVoidType(typespecParameters.body.type)) {
const effectiveBodyType = getEffectiveSchemaType(sdkContext, typespecParameters.body.type);
if (effectiveBodyType.kind === "Model") {
const bodyParameter = loadBodyParameter(sdkContext, effectiveBodyType);
Expand Down Expand Up @@ -199,6 +200,10 @@ export function loadOperation(
GenerateConvenienceMethod: generateConvenience,
} as InputOperation;

function isVoidType(type: Type): boolean {
return type.kind === "Intrinsic" && type.name === "void";
}

function loadOperationParameter(
context: SdkContext<NetEmitterOptions>,
parameter: HttpOperationParameter
Expand Down

0 comments on commit fc137a9

Please sign in to comment.