Skip to content
Merged
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: fix
packages:
- "@azure-tools/azure-http-specs"
---

Fix test cases for flatten property with read-only properties.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -186,7 +182,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.
Expand All @@ -198,13 +193,15 @@ model Solution {
}
```

Expected response body (properties flattened to parent level):
Expected response body:
```json
{
"name": "foo",
"solutionId": "solution1",
"title": "Solution Title",
"content": "Solution Content"
"properties": {
"solutionId": "solution1",
"title": "Solution Title",
"content": "Solution Content"
}
}
```
""")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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",
},
},
),
);
Loading