From fc2dbe2b5b492579d36e2f14ac68283c7002fc67 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Mon, 30 Mar 2026 05:22:03 +0000 Subject: [PATCH 1/3] feat: add HEAD payload e2e test scenario with response headers Co-authored-by: weidongxu-microsoft <53292327+weidongxu-microsoft@users.noreply.github.com> --- packages/http-specs/spec-summary.md | 11 ++++++ .../http-specs/specs/payload/head/main.tsp | 34 +++++++++++++++++++ .../http-specs/specs/payload/head/mockapi.ts | 17 ++++++++++ 3 files changed, 62 insertions(+) create mode 100644 packages/http-specs/specs/payload/head/main.tsp create mode 100644 packages/http-specs/specs/payload/head/mockapi.ts diff --git a/packages/http-specs/spec-summary.md b/packages/http-specs/spec-summary.md index bfcb5001593..defc1638410 100644 --- a/packages/http-specs/spec-summary.md +++ b/packages/http-specs/spec-summary.md @@ -1776,6 +1776,17 @@ Scenario that returns a different file encoding depending on the accept header. - image/png return a png image - image/jpeg return a jpeg image +### Payload_Head_getProperties + +- Endpoint: `head /payload/head/properties` + +A HEAD operation that returns response headers including Content-Type and x-ms-meta. + +Expected response headers: + +- Content-Type: text/plain +- x-ms-meta: hello + ### Payload_JsonMergePatch_createResource - Endpoint: `put /json-merge-patch/create/resource` diff --git a/packages/http-specs/specs/payload/head/main.tsp b/packages/http-specs/specs/payload/head/main.tsp new file mode 100644 index 00000000000..22cfe1d101c --- /dev/null +++ b/packages/http-specs/specs/payload/head/main.tsp @@ -0,0 +1,34 @@ +import "@typespec/http"; +import "@typespec/spector"; + +using Http; +using Spector; + +@doc("Test scenario for HEAD operation returning response headers.") +@scenarioService("/payload/head") +namespace Payload.Head; + +alias MetadataHeaders = { + /** The metadata headers. */ + @header("x-ms-meta") + metadata?: string; +}; + +@scenario +@scenarioDoc(""" + A HEAD operation that returns response headers including Content-Type and x-ms-meta. + + Expected response headers: + - Content-Type: text/plain + - x-ms-meta: hello + """) +@head +@route("/properties") +op getProperties(): { + /** Content-type. */ + #suppress "@typespec/http/content-type-ignored" "This is a HEAD operation, so content-type header can be returned." + @header("Content-Type") + contentType?: string; + + ...MetadataHeaders; +}; diff --git a/packages/http-specs/specs/payload/head/mockapi.ts b/packages/http-specs/specs/payload/head/mockapi.ts new file mode 100644 index 00000000000..d9e72887933 --- /dev/null +++ b/packages/http-specs/specs/payload/head/mockapi.ts @@ -0,0 +1,17 @@ +import { passOnSuccess, ScenarioMockApi } from "@typespec/spec-api"; + +export const Scenarios: Record = {}; + +Scenarios.Payload_Head_getProperties = passOnSuccess({ + uri: "/payload/head/properties", + method: "head", + request: {}, + response: { + status: 200, + headers: { + "content-type": "text/plain", + "x-ms-meta": "hello", + }, + }, + kind: "MockApiDefinition", +}); From 60ea041c3515182d73a3a2b0b582a346658ff172 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Mon, 30 Mar 2026 05:22:14 +0000 Subject: [PATCH 2/3] feat: add HEAD payload e2e test scenario with response headers + changelog Agent-Logs-Url: https://github.com/microsoft/typespec/sessions/39724eb3-1f39-4fa7-ac6f-8ff2ed9a37f5 Co-authored-by: weidongxu-microsoft <53292327+weidongxu-microsoft@users.noreply.github.com> --- .../copilot-add-e2e-test-scenario-2026-2-30-5-22-8.md | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 .chronus/changes/copilot-add-e2e-test-scenario-2026-2-30-5-22-8.md diff --git a/.chronus/changes/copilot-add-e2e-test-scenario-2026-2-30-5-22-8.md b/.chronus/changes/copilot-add-e2e-test-scenario-2026-2-30-5-22-8.md new file mode 100644 index 00000000000..7b67b834c0c --- /dev/null +++ b/.chronus/changes/copilot-add-e2e-test-scenario-2026-2-30-5-22-8.md @@ -0,0 +1,7 @@ +--- +changeKind: feature +packages: + - "@typespec/http-specs" +--- + +Add HEAD payload e2e test scenario with Content-Type and x-ms-meta response headers \ No newline at end of file From 84089d78bb8dc2f0a1fdd3ef15058dd1a71dfaa8 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Mon, 30 Mar 2026 05:54:57 +0000 Subject: [PATCH 3/3] fix: update content-type to text/plain; charset=utf-8 in HEAD payload scenario Agent-Logs-Url: https://github.com/microsoft/typespec/sessions/396839eb-f0c5-46c6-aea3-30bc0b49c85a Co-authored-by: weidongxu-microsoft <53292327+weidongxu-microsoft@users.noreply.github.com> --- packages/http-specs/spec-summary.md | 2 +- packages/http-specs/specs/payload/head/main.tsp | 2 +- packages/http-specs/specs/payload/head/mockapi.ts | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/http-specs/spec-summary.md b/packages/http-specs/spec-summary.md index defc1638410..462a9050b1f 100644 --- a/packages/http-specs/spec-summary.md +++ b/packages/http-specs/spec-summary.md @@ -1784,7 +1784,7 @@ A HEAD operation that returns response headers including Content-Type and x-ms-m Expected response headers: -- Content-Type: text/plain +- Content-Type: text/plain; charset=utf-8 - x-ms-meta: hello ### Payload_JsonMergePatch_createResource diff --git a/packages/http-specs/specs/payload/head/main.tsp b/packages/http-specs/specs/payload/head/main.tsp index 22cfe1d101c..3f3a3d3b9f1 100644 --- a/packages/http-specs/specs/payload/head/main.tsp +++ b/packages/http-specs/specs/payload/head/main.tsp @@ -19,7 +19,7 @@ alias MetadataHeaders = { A HEAD operation that returns response headers including Content-Type and x-ms-meta. Expected response headers: - - Content-Type: text/plain + - Content-Type: text/plain; charset=utf-8 - x-ms-meta: hello """) @head diff --git a/packages/http-specs/specs/payload/head/mockapi.ts b/packages/http-specs/specs/payload/head/mockapi.ts index d9e72887933..fed356abe9c 100644 --- a/packages/http-specs/specs/payload/head/mockapi.ts +++ b/packages/http-specs/specs/payload/head/mockapi.ts @@ -9,7 +9,7 @@ Scenarios.Payload_Head_getProperties = passOnSuccess({ response: { status: 200, headers: { - "content-type": "text/plain", + "content-type": "text/plain; charset=utf-8", "x-ms-meta": "hello", }, },