From 8de6d550aea84c4505230232aebd51dc4f6f792a Mon Sep 17 00:00:00 2001 From: "Jiao Di (MSFT)" Date: Wed, 4 Mar 2026 09:56:59 +0800 Subject: [PATCH 1/5] fix flatten case --- .../azure/client-generator-core/flatten-property/main.tsp | 5 +++-- .../client-generator-core/flatten-property/mockapi.ts | 8 +++++--- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/packages/azure-http-specs/specs/azure/client-generator-core/flatten-property/main.tsp b/packages/azure-http-specs/specs/azure/client-generator-core/flatten-property/main.tsp index 7caf563c6b..03a587cc14 100644 --- a/packages/azure-http-specs/specs/azure/client-generator-core/flatten-property/main.tsp +++ b/packages/azure-http-specs/specs/azure/client-generator-core/flatten-property/main.tsp @@ -186,7 +186,6 @@ model Solution { Expected behavior: When flattening a property that contains only read-only properties: - For input (write): Read-only properties should not appear in the input model, regardless of flattening - - For response (read): Read-only properties should be flattened to the parent model level The `properties` and `propertiesOptional` fields contain only read-only properties (`solutionId`, `title`, `content`). These should be flattened into the parent `Solution` model in the response. @@ -198,13 +197,15 @@ model Solution { } ``` - Expected response body (properties flattened to parent level): + Expected response body: ```json { "name": "foo", + "properties": { "solutionId": "solution1", "title": "Solution Title", "content": "Solution Content" + } } ``` """) diff --git a/packages/azure-http-specs/specs/azure/client-generator-core/flatten-property/mockapi.ts b/packages/azure-http-specs/specs/azure/client-generator-core/flatten-property/mockapi.ts index 67547ad2b9..da6c9d9157 100644 --- a/packages/azure-http-specs/specs/azure/client-generator-core/flatten-property/mockapi.ts +++ b/packages/azure-http-specs/specs/azure/client-generator-core/flatten-property/mockapi.ts @@ -86,9 +86,11 @@ Scenarios.Azure_ClientGenerator_Core_FlattenProperty_putFlattenReadOnlyModel = p }, { name: "foo", - solutionId: "solution1", - title: "Solution Title", - content: "Solution Content", + properties: { + solutionId: "solution1", + title: "Solution Title", + content: "Solution Content", + } }, ), ); From 33a0c0c05eeee58972b5812309ce223dfc2f2acd Mon Sep 17 00:00:00 2001 From: "Jiao Di (MSFT)" Date: Wed, 4 Mar 2026 10:06:54 +0800 Subject: [PATCH 2/5] update --- .../fix-flatten-property-tests-2026-03-04-10-56-42.md | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 .chronus/changes/fix-flatten-property-tests-2026-03-04-10-56-42.md diff --git a/.chronus/changes/fix-flatten-property-tests-2026-03-04-10-56-42.md b/.chronus/changes/fix-flatten-property-tests-2026-03-04-10-56-42.md new file mode 100644 index 0000000000..2fbe56ce69 --- /dev/null +++ b/.chronus/changes/fix-flatten-property-tests-2026-03-04-10-56-42.md @@ -0,0 +1,7 @@ +--- +changeKind: fix +packages: + - "@azure-tools/azure-http-specs" +--- + +Fix test cases for flatten property with read-only properties. From 417f12120614a04168d4e27220776f2d4ea92a83 Mon Sep 17 00:00:00 2001 From: "Jiao Di (MSFT)" Date: Thu, 5 Mar 2026 10:32:51 +0800 Subject: [PATCH 3/5] format --- .../client-generator-core/flatten-property/mockapi.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/packages/azure-http-specs/specs/azure/client-generator-core/flatten-property/mockapi.ts b/packages/azure-http-specs/specs/azure/client-generator-core/flatten-property/mockapi.ts index da6c9d9157..38d70be79a 100644 --- a/packages/azure-http-specs/specs/azure/client-generator-core/flatten-property/mockapi.ts +++ b/packages/azure-http-specs/specs/azure/client-generator-core/flatten-property/mockapi.ts @@ -87,10 +87,10 @@ Scenarios.Azure_ClientGenerator_Core_FlattenProperty_putFlattenReadOnlyModel = p { name: "foo", properties: { - solutionId: "solution1", - title: "Solution Title", - content: "Solution Content", - } + solutionId: "solution1", + title: "Solution Title", + content: "Solution Content", + }, }, ), ); From 54592dea8238a31ef99a9f9ca30b402c1fe7d5e6 Mon Sep 17 00:00:00 2001 From: "Jiao Di (MSFT)" Date: Thu, 5 Mar 2026 15:25:06 +0800 Subject: [PATCH 4/5] update --- .../azure/client-generator-core/flatten-property/main.tsp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/azure-http-specs/specs/azure/client-generator-core/flatten-property/main.tsp b/packages/azure-http-specs/specs/azure/client-generator-core/flatten-property/main.tsp index 03a587cc14..42b659615c 100644 --- a/packages/azure-http-specs/specs/azure/client-generator-core/flatten-property/main.tsp +++ b/packages/azure-http-specs/specs/azure/client-generator-core/flatten-property/main.tsp @@ -202,9 +202,9 @@ model Solution { { "name": "foo", "properties": { - "solutionId": "solution1", - "title": "Solution Title", - "content": "Solution Content" + "solutionId": "solution1", + "title": "Solution Title", + "content": "Solution Content" } } ``` From 8a3426d7110f13ff2680a1b8bf26ad75b5935ea4 Mon Sep 17 00:00:00 2001 From: "Jiao Di (MSFT)" Date: Thu, 5 Mar 2026 17:12:07 +0800 Subject: [PATCH 5/5] remove require flatten property --- .../azure/client-generator-core/flatten-property/main.tsp | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/packages/azure-http-specs/specs/azure/client-generator-core/flatten-property/main.tsp b/packages/azure-http-specs/specs/azure/client-generator-core/flatten-property/main.tsp index 42b659615c..5a92e439b4 100644 --- a/packages/azure-http-specs/specs/azure/client-generator-core/flatten-property/main.tsp +++ b/packages/azure-http-specs/specs/azure/client-generator-core/flatten-property/main.tsp @@ -172,11 +172,7 @@ model Solution { #suppress "@azure-tools/typespec-azure-core/no-legacy-usage" "Testing backcompat" @global.Azure.ClientGenerator.Core.Legacy.flattenProperty - properties: SolutionProperties; - - #suppress "@azure-tools/typespec-azure-core/no-legacy-usage" "Testing backcompat" - @global.Azure.ClientGenerator.Core.Legacy.flattenProperty - propertiesOptional?: SolutionProperties; + properties?: SolutionProperties; } @scenario