Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
25 changes: 25 additions & 0 deletions packages/typespec-powershell/src/convertor/convertor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
(<any>finalResponse).schema = schema;

newOperation.responses.push(finalResponse);
}
}
}

function createBodyParameter(psContext: SdkContext, parameter: HttpOperationBody, model: PwshModel): Parameter {
Expand Down
2 changes: 1 addition & 1 deletion packages/typespec-powershell/src/utils/modelUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
Loading