From 9b6dd76656ece38c02a6a6db60ce7f8417808ee5 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Mon, 12 Jan 2026 04:54:10 +0000 Subject: [PATCH 1/8] Initial plan From 9912d57810cd6b51b500a1fb120c634c9c855840 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Mon, 12 Jan 2026 05:08:47 +0000 Subject: [PATCH 2/8] Add pipe-delimited enum array test case to encode/array spec Co-authored-by: weidongxu-microsoft <53292327+weidongxu-microsoft@users.noreply.github.com> --- packages/http-specs/spec-summary.md | 21 ++++++++++++ .../http-specs/specs/encode/array/main.tsp | 33 +++++++++++++++++++ .../http-specs/specs/encode/array/mockapi.ts | 5 +++ 3 files changed, 59 insertions(+) diff --git a/packages/http-specs/spec-summary.md b/packages/http-specs/spec-summary.md index a265b83066f..f32db522642 100644 --- a/packages/http-specs/spec-summary.md +++ b/packages/http-specs/spec-summary.md @@ -168,6 +168,27 @@ Expected response body: } ``` +### Encode_Array_Property_pipeDelimitedEnumElement + +- Endpoint: `post /encode/array/property/pipe-delimited-enum-element` + +Test operation with request and response model contains an enum array property with pipeDelimited encode. +Expected request body: + +```json +{ + "value": "blue|red|green" +} +``` + +Expected response body: + +```json +{ + "value": "blue|red|green" +} +``` + ### Encode_Array_Property_spaceDelimited - Endpoint: `post /encode/array/property/space-delimited` diff --git a/packages/http-specs/specs/encode/array/main.tsp b/packages/http-specs/specs/encode/array/main.tsp index 4e707eeb41d..a3f0184b944 100644 --- a/packages/http-specs/specs/encode/array/main.tsp +++ b/packages/http-specs/specs/encode/array/main.tsp @@ -8,6 +8,12 @@ using Spector; @scenarioService("/encode/array") namespace Encode.Array; +enum Color { + blue, + red, + green, +} + model CommaDelimitedArrayProperty { @encode(ArrayEncoding.commaDelimited) value: string[]; @@ -28,6 +34,11 @@ model NewlineDelimitedArrayProperty { value: string[]; } +model PipeDelimitedArrayEnumElementProperty { + @encode(ArrayEncoding.pipeDelimited) + value: Color[]; +} + @route("/property") namespace Property { @route("/comma-delimited") @@ -109,4 +120,26 @@ namespace Property { """) @post op newlineDelimited(@body body: NewlineDelimitedArrayProperty): NewlineDelimitedArrayProperty; + + @route("/pipe-delimited-enum-element") + @scenario + @scenarioDoc(""" + Test operation with request and response model contains an enum array property with pipeDelimited encode. + Expected request body: + ```json + { + "value": "blue|red|green" + } + ``` + Expected response body: + ```json + { + "value": "blue|red|green" + } + ``` + """) + @post + op pipeDelimitedEnumElement( + @body body: PipeDelimitedArrayEnumElementProperty, + ): PipeDelimitedArrayEnumElementProperty; } diff --git a/packages/http-specs/specs/encode/array/mockapi.ts b/packages/http-specs/specs/encode/array/mockapi.ts index 8b22eeb67ea..9ed503e474c 100644 --- a/packages/http-specs/specs/encode/array/mockapi.ts +++ b/packages/http-specs/specs/encode/array/mockapi.ts @@ -41,3 +41,8 @@ Scenarios.Encode_Array_Property_newlineDelimited = createPropertyServerTests( "/encode/array/property/newline-delimited", "\n", ); + +Scenarios.Encode_Array_Property_pipeDelimitedEnumElement = createPropertyServerTests( + "/encode/array/property/pipe-delimited-enum-element", + "|", +); From a6207a12aff078dd36f5171fae4592f70bdbf1c4 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Mon, 12 Jan 2026 05:55:41 +0000 Subject: [PATCH 3/8] Change Color from enum to extensible union Co-authored-by: weidongxu-microsoft <53292327+weidongxu-microsoft@users.noreply.github.com> --- packages/http-specs/specs/encode/array/main.tsp | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/packages/http-specs/specs/encode/array/main.tsp b/packages/http-specs/specs/encode/array/main.tsp index a3f0184b944..8ebaaad59ab 100644 --- a/packages/http-specs/specs/encode/array/main.tsp +++ b/packages/http-specs/specs/encode/array/main.tsp @@ -8,10 +8,12 @@ using Spector; @scenarioService("/encode/array") namespace Encode.Array; -enum Color { - blue, - red, - green, +union Color { + string, + + Blue: "blue", + Red: "red", + Green: "green", } model CommaDelimitedArrayProperty { From 29d774bc1b5a8f17a6d7d9a84282b8963b806222 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Mon, 12 Jan 2026 05:57:05 +0000 Subject: [PATCH 4/8] Update documentation to reflect extensible union instead of enum Co-authored-by: weidongxu-microsoft <53292327+weidongxu-microsoft@users.noreply.github.com> --- packages/http-specs/specs/encode/array/main.tsp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/http-specs/specs/encode/array/main.tsp b/packages/http-specs/specs/encode/array/main.tsp index 8ebaaad59ab..cac6f3b9376 100644 --- a/packages/http-specs/specs/encode/array/main.tsp +++ b/packages/http-specs/specs/encode/array/main.tsp @@ -126,7 +126,7 @@ namespace Property { @route("/pipe-delimited-enum-element") @scenario @scenarioDoc(""" - Test operation with request and response model contains an enum array property with pipeDelimited encode. + Test operation with request and response model contains an extensible union array property with pipeDelimited encode. Expected request body: ```json { From aab8d3aed0d1d7a0ec1a2562f294885a4f294823 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Mon, 12 Jan 2026 06:03:06 +0000 Subject: [PATCH 5/8] Add changelog entry for ArrayEncoding extensible union test Co-authored-by: weidongxu-microsoft <53292327+weidongxu-microsoft@users.noreply.github.com> --- ...opilot-add-array-encoding-test-case-2026-0-12-6-2-30.md | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 .chronus/changes/copilot-add-array-encoding-test-case-2026-0-12-6-2-30.md diff --git a/.chronus/changes/copilot-add-array-encoding-test-case-2026-0-12-6-2-30.md b/.chronus/changes/copilot-add-array-encoding-test-case-2026-0-12-6-2-30.md new file mode 100644 index 00000000000..7ffefca44cf --- /dev/null +++ b/.chronus/changes/copilot-add-array-encoding-test-case-2026-0-12-6-2-30.md @@ -0,0 +1,7 @@ +--- +changeKind: feature +packages: + - "@typespec/http-specs" +--- + +Add test case for ArrayEncoding with extensible union \ No newline at end of file From 7606e5085e758aee850622b9ea10d4d38743cdc0 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Mon, 12 Jan 2026 06:12:35 +0000 Subject: [PATCH 6/8] Co-authored-by: weidongxu-microsoft <53292327+weidongxu-microsoft@users.noreply.github.com> --- packages/http-specs/spec-summary.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/http-specs/spec-summary.md b/packages/http-specs/spec-summary.md index f32db522642..dbe680977a8 100644 --- a/packages/http-specs/spec-summary.md +++ b/packages/http-specs/spec-summary.md @@ -172,7 +172,7 @@ Expected response body: - Endpoint: `post /encode/array/property/pipe-delimited-enum-element` -Test operation with request and response model contains an enum array property with pipeDelimited encode. +Test operation with request and response model contains an extensible union array property with pipeDelimited encode. Expected request body: ```json From bf398efcb984752d78467d8bd2aeca27490f45ad Mon Sep 17 00:00:00 2001 From: Weidong Xu Date: Mon, 12 Jan 2026 14:16:27 +0800 Subject: [PATCH 7/8] format --- packages/http-specs/specs/encode/array/main.tsp | 1 - 1 file changed, 1 deletion(-) diff --git a/packages/http-specs/specs/encode/array/main.tsp b/packages/http-specs/specs/encode/array/main.tsp index cac6f3b9376..36cc1cbfedc 100644 --- a/packages/http-specs/specs/encode/array/main.tsp +++ b/packages/http-specs/specs/encode/array/main.tsp @@ -10,7 +10,6 @@ namespace Encode.Array; union Color { string, - Blue: "blue", Red: "red", Green: "green", From 36029ef1885552aebb8e972df8cc324fbd66c889 Mon Sep 17 00:00:00 2001 From: Weidong Xu Date: Mon, 12 Jan 2026 14:19:01 +0800 Subject: [PATCH 8/8] call it "extensible enum" --- packages/http-specs/spec-summary.md | 2 +- packages/http-specs/specs/encode/array/main.tsp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/http-specs/spec-summary.md b/packages/http-specs/spec-summary.md index dbe680977a8..31fc2dc0877 100644 --- a/packages/http-specs/spec-summary.md +++ b/packages/http-specs/spec-summary.md @@ -172,7 +172,7 @@ Expected response body: - Endpoint: `post /encode/array/property/pipe-delimited-enum-element` -Test operation with request and response model contains an extensible union array property with pipeDelimited encode. +Test operation with request and response model contains an extensible enum array property with pipeDelimited encode. Expected request body: ```json diff --git a/packages/http-specs/specs/encode/array/main.tsp b/packages/http-specs/specs/encode/array/main.tsp index 36cc1cbfedc..8f49a7e999f 100644 --- a/packages/http-specs/specs/encode/array/main.tsp +++ b/packages/http-specs/specs/encode/array/main.tsp @@ -125,7 +125,7 @@ namespace Property { @route("/pipe-delimited-enum-element") @scenario @scenarioDoc(""" - Test operation with request and response model contains an extensible union array property with pipeDelimited encode. + Test operation with request and response model contains an extensible enum array property with pipeDelimited encode. Expected request body: ```json {