From 46e6c85458becf89b07fd9b27673ba0c83cad50b Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Thu, 8 Jan 2026 02:17:39 +0000 Subject: [PATCH 1/3] Initial plan From dc9e8bbb6ac45cbad7b94bafa47256ce15eae726 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Thu, 8 Jan 2026 02:30:28 +0000 Subject: [PATCH 2/3] Add tests for flatten property with unknown type and read-only properties Co-authored-by: v-jiaodi <80496810+v-jiaodi@users.noreply.github.com> --- .../flatten-property/main.tsp | 90 +++++++++++++++++++ .../flatten-property/mockapi.ts | 35 ++++++++ 2 files changed, 125 insertions(+) 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 242d49ece4..f0861bb7fc 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 @@ -1,10 +1,12 @@ import "@typespec/http"; import "@typespec/spector"; import "@azure-tools/typespec-client-generator-core"; +import "@azure-tools/typespec-azure-core"; using Http; using global.Azure.ClientGenerator.Core; using Spector; +using global.Azure.Core; @doc("Illustrates the model flatten cases.") @scenarioService("/azure/client-generator-core/flatten-property") @@ -110,3 +112,91 @@ op putFlattenModel(@body input: FlattenModel): FlattenModel; """) @put op putNestedFlattenModel(@body input: NestedFlattenModel): NestedFlattenModel; + +@doc("This is the model with unknown type properties to be flattened.") +model FlattenUnknownModel { + name: string; + + #suppress "@azure-tools/typespec-azure-core/no-unknown" "For testing purposes" + #suppress "@azure-tools/typespec-azure-core/no-legacy-usage" "Testing backcompat" + @global.Azure.ClientGenerator.Core.Legacy.flattenProperty + properties?: unknown; +} + +@scenario +@route("/flattenUnknownModel") +@scenarioDoc(""" + Update and receive model with flatten property of unknown type. + Expected input body: + ```json + { + "name": "foo" + } + ``` + + Expected response body: + ```json + { + "name": "test", + "properties": { + "key1": "value1", + "key2": "value2" + } + } + ``` + """) +@put +op putFlattenUnknownModel(@body input: FlattenUnknownModel): FlattenUnknownModel; + +@doc("This is the model with all read-only properties to be flattened.") +model SolutionProperties { + @visibility(Lifecycle.Read) + solutionId?: string; + + @visibility(Lifecycle.Read) + title?: string; + + @visibility(Lifecycle.Read) + content?: string; +} + +@doc("This is the model with flattened properties that are all read-only.") +model Solution { + name: string; + + #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; +} + +@scenario +@route("/flattenReadOnlyModel") +@scenarioDoc(""" + Test model with flatten property containing all read-only properties. + Expected input body: + ```json + { + "name": "foo", + "properties": {}, + "propertiesOptional": {} + } + ``` + + Expected response body: + ```json + { + "name": "test", + "properties": { + "solutionId": "solution1", + "title": "Solution Title", + "content": "Solution Content" + } + } + ``` + """) +@put +op putFlattenReadOnlyModel(@body body: Solution): Solution; 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 8b5205d8f9..422f19579e 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 @@ -61,3 +61,38 @@ Scenarios.Azure_ClientGenerator_Core_FlattenProperty_putNestedFlattenModel = pas }, ), ); + +Scenarios.Azure_ClientGenerator_Core_FlattenProperty_putFlattenUnknownModel = passOnSuccess( + createMockApiDefinitions( + "flattenUnknownModel", + { + name: "foo", + }, + { + name: "test", + properties: { + key1: "value1", + key2: "value2", + }, + }, + ), +); + +Scenarios.Azure_ClientGenerator_Core_FlattenProperty_putFlattenReadOnlyModel = passOnSuccess( + createMockApiDefinitions( + "flattenReadOnlyModel", + { + name: "foo", + properties: {}, + propertiesOptional: {}, + }, + { + name: "test", + properties: { + solutionId: "solution1", + title: "Solution Title", + content: "Solution Content", + }, + }, + ), +); From 260bfdf8ac67d1b4ba4c8b9ebce4fee773bb9473 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Thu, 22 Jan 2026 09:18:53 +0000 Subject: [PATCH 3/3] Remove unused Azure.Core imports Co-authored-by: v-jiaodi <80496810+v-jiaodi@users.noreply.github.com> --- .../specs/azure/client-generator-core/flatten-property/main.tsp | 2 -- 1 file changed, 2 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 f0861bb7fc..8bccd8dc31 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 @@ -1,12 +1,10 @@ import "@typespec/http"; import "@typespec/spector"; import "@azure-tools/typespec-client-generator-core"; -import "@azure-tools/typespec-azure-core"; using Http; using global.Azure.ClientGenerator.Core; using Spector; -using global.Azure.Core; @doc("Illustrates the model flatten cases.") @scenarioService("/azure/client-generator-core/flatten-property")