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 diff --git a/packages/http-specs/spec-summary.md b/packages/http-specs/spec-summary.md index bfcb5001593..e3dba903378 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_contentTypeHeaderInResponse + +- Endpoint: `head /payload/head/content-type-header-in-response` + +A HEAD operation that returns response headers including Content-Type and x-ms-meta. + +Expected response headers: + +- Content-Type: text/plain; charset=utf-8 +- 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..ed3238097d8 --- /dev/null +++ b/packages/http-specs/specs/payload/head/main.tsp @@ -0,0 +1,33 @@ +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; charset=utf-8 + - x-ms-meta: hello + """) +@head +@route("/content-type-header-in-response") +op contentTypeHeaderInResponse(): { + /** Content-type. */ + @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..5284d461311 --- /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_contentTypeHeaderInResponse = passOnSuccess({ + uri: "/payload/head/content-type-header-in-response", + method: "head", + request: {}, + response: { + status: 200, + headers: { + "content-type": "text/plain; charset=utf-8", + "x-ms-meta": "hello", + }, + }, + kind: "MockApiDefinition", +});