Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Jan 19, 2026

Adds a new test case for POST LRO operations where the final response type is bytes, enabling SDK generators to validate binary response handling in long-running operations.

Changes

  • lro.tsp: Added exportBinary operation using ArmResourceActionAsync with ExportBinaryResult returning @body data: bytes with application/octet-stream content type
  • mockapi.ts: Added mock handlers for the LRO flow (initial 202, AAO polling, Location polling returning binary)
  • helper.ts + assets/image.png: New helper module and test asset for binary response payload

Example TypeSpec Definition

model ExportBinaryResult {
  @header contentType: "application/octet-stream";
  @body data: bytes;
}

exportBinary is ArmResourceActionAsync<
  Order,
  ExportBinaryRequest,
  ExportBinaryResult,
  LroHeaders = ArmCombinedLroHeaders<FinalResult = ExportBinaryResult> &
    Azure.Core.Foundations.RetryAfterHeader
>;

The operation follows the standard ARM LRO pattern with both Location and Azure-AsyncOperation headers, returning binary content on final Location poll.

Original prompt

This section details on the original issue you should resolve

<issue_title>[spector] Add a POST long running API whose response type is bytes</issue_title>
<issue_description>GOAL:

add test case in https://github.com/Azure/typespec-azure/blob/a68aa69f03652b819048638e0eb593478c35f2c6/packages/azure-http-specs/specs/azure/resource-manager/operation-templates/lro.tsp for POST LRO whose response type is bytes.

Context:
You could refer to playground :

import "@typespec/http";
import "@azure-tools/typespec-azure-core";
import "@azure-tools/typespec-azure-resource-manager";

using Http;
using Rest;
using Versioning;
using Azure.Core;
using Azure.ResourceManager;

@armProviderNamespace
@service(#{ title: "Binary Export Service" })
@versioned(Versions)
namespace Contoso.BinaryExport;

enum Versions {
  @armCommonTypesVersion(Azure.ResourceManager.CommonTypes.Versions.v5)
  `2024-06-01`,
}

model ExportRequest {
  sourceId: string;
}

// LRO: POST returns 202, final result is bytes
@action("export")
op exportBinary is ArmResourceActionAsync<
  // Resource type (for RBAC, etc.)
  ExportResource,
  // Request body type
  ExportRequest,
  // Final response type (bytes)
  {@body data: bytes}
>;

model ExportResource is TrackedResource<{}> {
  ...ResourceNameParameter<ExportResource>;
}

NOTE:

Comments on the Issue (you are @copilot in this section)

@msyyc Context: From issue https://github.com/Azure/autorest.python/issues/3247, I know that https://github.com/microsoft/fabric-rest-api-specs is using swagger and swagger codegen tool. If we hope them to migrate to Typespec, we should support their desired feature.

💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Co-authored-by: msyyc <70930885+msyyc@users.noreply.github.com>
Copilot AI changed the title [WIP] Add POST long running API with bytes response type Add POST LRO test case with bytes response type Jan 19, 2026
Copilot AI requested a review from msyyc January 19, 2026 03:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[spector] Add a POST long running API whose response type is bytes

2 participants