Skip to content

Add POST LRO test case with bytes response type#3793

Draft
Copilot wants to merge 2 commits intomainfrom
copilot/add-post-long-running-api
Draft

Add POST LRO test case with bytes response type#3793
Copilot wants to merge 2 commits intomainfrom
copilot/add-post-long-running-api

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
@microsoft-github-policy-service microsoft-github-policy-service bot added the stale Mark a PR that hasn't been recently updated and will be closed. label Feb 18, 2026
@microsoft-github-policy-service

Hi @@copilot. Your PR has had no update for 30 days and it is marked as a stale PR. If it is not updated within 30 days, the PR will automatically be closed. If you want to refresh the PR, please remove the stale label.

@timotheeguerin timotheeguerin added the lib:azure-http-specs For issues/prs related to the @azure-tools/typespec-azure-http-specs package label Mar 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

lib:azure-http-specs For issues/prs related to the @azure-tools/typespec-azure-http-specs package stale Mark a PR that hasn't been recently updated and will be closed.

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

3 participants