diff --git a/.chronus/changes/add-list-property-test-2025-12-22-08-19-30.md b/.chronus/changes/add-list-property-test-2025-12-22-08-19-30.md new file mode 100644 index 00000000000..d5e233b0585 --- /dev/null +++ b/.chronus/changes/add-list-property-test-2025-12-22-08-19-30.md @@ -0,0 +1,7 @@ +--- +changeKind: internal +packages: + - "@typespec/http-specs" +--- + +Add test case for model property named "list" to cover special word scenarios diff --git a/packages/http-specs/spec-summary.md b/packages/http-specs/spec-summary.md index cb3674d16d9..f2c7273d7d4 100644 --- a/packages/http-specs/spec-summary.md +++ b/packages/http-specs/spec-summary.md @@ -3517,6 +3517,18 @@ Send { "SameAsModel": "ok" } ``` +### SpecialWords_ModelProperties_withList + +- Endpoint: `get /special-words/model-properties/list` + +Verify that a property can be named "list", which is a reserved word in many languages like Python. + +Send + +```json +{ "list": "ok" } +``` + ### SpecialWords_Models_and - Endpoint: `get /special-words/models/and` diff --git a/packages/http-specs/specs/special-words/main.tsp b/packages/http-specs/specs/special-words/main.tsp index 2705d858905..a48f1a3f257 100644 --- a/packages/http-specs/specs/special-words/main.tsp +++ b/packages/http-specs/specs/special-words/main.tsp @@ -34,6 +34,7 @@ using Spector; * in * is * lambda + * list * not * or * pass @@ -269,4 +270,22 @@ namespace ModelProperties { """) @route("dict-methods") op dictMethods(@body body: DictMethods): void; + + // Test for model property named "list" which is a reserved word in many languages + model ModelWithList { + list: string; + } + + @scenario + @scenarioDoc(""" + Verify that a property can be named "list", which is a reserved word in many languages like Python. + + Send + + ```json + {"list": "ok"} + ``` + """) + @route("list") + op withList(@body body: ModelWithList): void; } diff --git a/packages/http-specs/specs/special-words/mockapi.ts b/packages/http-specs/specs/special-words/mockapi.ts index 4d2883b10f1..8076c8b7d4c 100644 --- a/packages/http-specs/specs/special-words/mockapi.ts +++ b/packages/http-specs/specs/special-words/mockapi.ts @@ -39,6 +39,20 @@ Scenarios.SpecialWords_ModelProperties_dictMethods = passOnSuccess({ kind: "MockApiDefinition", }); +Scenarios.SpecialWords_ModelProperties_withList = passOnSuccess({ + uri: "/special-words/model-properties/list", + method: "post", + request: { + body: json({ + list: "ok", + }), + }, + response: { + status: 204, + }, + kind: "MockApiDefinition", +}); + function createModelsTests(uri: string) { return passOnSuccess({ uri,