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..462a9050b1f 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; 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..3f3a3d3b9f1 --- /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; charset=utf-8 + - 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..fed356abe9c --- /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; charset=utf-8", + "x-ms-meta": "hello", + }, + }, + kind: "MockApiDefinition", +});