Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -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
11 changes: 11 additions & 0 deletions packages/http-specs/spec-summary.md
Original file line number Diff line number Diff line change
Expand Up @@ -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`
Expand Down
34 changes: 34 additions & 0 deletions packages/http-specs/specs/payload/head/main.tsp
Original file line number Diff line number Diff line change
@@ -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;
};
17 changes: 17 additions & 0 deletions packages/http-specs/specs/payload/head/mockapi.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import { passOnSuccess, ScenarioMockApi } from "@typespec/spec-api";

export const Scenarios: Record<string, ScenarioMockApi> = {};

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",
});
Loading