diff --git a/packages/typespec-powershell/src/convertor/convertor.ts b/packages/typespec-powershell/src/convertor/convertor.ts index 408c926b20f..1f0235b6b81 100644 --- a/packages/typespec-powershell/src/convertor/convertor.ts +++ b/packages/typespec-powershell/src/convertor/convertor.ts @@ -336,6 +336,31 @@ function addResponses(psContext: SdkContext, op: HttpOperation, newOperation: Op } } } + + // Add LRO final result response if it exists + const lro = getLroMetadata(psContext.program, op.operation); + if (lro && lro.finalResult && lro.finalResult !== "void") { + // Check if there's already a 200 status code response + const has200Response = newOperation.responses.some(response => + response.protocol.http?.statusCodes?.includes("200") + ); + + if (!has200Response) { + const finalResponse = new Response(); + finalResponse.language.default.name = ''; + finalResponse.language.default.description = "Final result of the long running operation"; + finalResponse.protocol.http = finalResponse.protocol.http ?? new Protocol(); + finalResponse.protocol.http.statusCodes = ["200"]; + finalResponse.protocol.http.knownMediaType = "json"; + finalResponse.protocol.http.mediaTypes = ["application/json"]; + + // Add schema for the final result + const schema = getSchemaForType(psContext, lro.finalResult); + (finalResponse).schema = schema; + + newOperation.responses.push(finalResponse); + } + } } function createBodyParameter(psContext: SdkContext, parameter: HttpOperationBody, model: PwshModel): Parameter { diff --git a/packages/typespec-powershell/src/utils/modelUtils.ts b/packages/typespec-powershell/src/utils/modelUtils.ts index aaca20e21a4..9fe5d2cd472 100644 --- a/packages/typespec-powershell/src/utils/modelUtils.ts +++ b/packages/typespec-powershell/src/utils/modelUtils.ts @@ -1377,7 +1377,7 @@ function getSchemaForStdScalar( const description = getSummary(dpgContext.program, type); switch (name) { case "bytes": - return { type: "string", format: "bytes", description }; + return { type: SchemaType.ByteArray, description }; case "integer": return applyIntrinsicDecorators(dpgContext, type, { type: "integer"