Conversation
Co-authored-by: v-jiaodi <80496810+v-jiaodi@users.noreply.github.com>
T[] directly instead of { body: T[] } when wrap-non-model-return is enabled
|
@copilot for |
… behavior Co-authored-by: v-jiaodi <80496810+v-jiaodi@users.noreply.github.com>
Fixed in commit 3038f36. When |
T[] directly instead of { body: T[] } when wrap-non-model-return is enabledwrap-non-model-return is enabled
…onse alias Co-authored-by: v-jiaodi <80496810+v-jiaodi@users.noreply.github.com> Agent-Logs-Url: https://github.com/Azure/autorest.typescript/sessions/6e436425-0256-49d0-8f11-05e4ff1ace61
|
@copilot fix smoke ci error and integration test ci error. |
|
@copilot fix smoke ci error and integration test ci error. |
….body wrapper) Co-authored-by: v-jiaodi <80496810+v-jiaodi@users.noreply.github.com> Agent-Logs-Url: https://github.com/Azure/autorest.typescript/sessions/1b0cb8e1-c52f-4dcb-a032-712f3d13d44d
Fixed in commit 9434ce2. Updated the three failing spec files and regenerated the affected generated declaration files:
All 894 azure-modular integration tests pass. |
Co-authored-by: v-jiaodi <80496810+v-jiaodi@users.noreply.github.com> Agent-Logs-Url: https://github.com/Azure/autorest.typescript/sessions/1b0cb8e1-c52f-4dcb-a032-712f3d13d44d
| export function checkWrapNonModelReturn( | ||
| context: SdkContext, | ||
| operation: ServiceOperation | ||
| ): { shouldWrap: boolean; isBinary: boolean } { |
There was a problem hiding this comment.
we don't need to maitain XXXResponse for model array and any object, so we could only adjust shouldWrap contiditon.
There was a problem hiding this comment.
@copilot revert src and ut files change. Apply a fix as described below:
confirmed the logic in HLC we would only wrap with body when the type is not PropertyKind.Composite or PropertyKind.Dictionary and for array type its kind is from its array item.
So the mapping is:
- string → PropertyKind.Primitive -> wrapper
- boolean → PropertyKind.Primitive -> wrapper
- string[] → PropertyKind.Primitive (array keeps item kind) -> wrapper
- any → PropertyKind.Primitive -> wrapper
- enum → PropertyKind.Enum -> wrapper
- model array (Foo[]) → PropertyKind.Composite (array keeps item kind from Foo) -> no wrapper
- any object (SchemaType.AnyObject) → PropertyKind.Dictionary -> no wrapper
There was a problem hiding this comment.
Done in commit 91cd9bc. Reverted operationHelpers.ts and emitModels.ts to main's approach (no isModelArray/isUnknown flags), and applied the fix solely by adjusting shouldWrap: added a single condition in checkWrapNonModelReturn to return noWrap when type.kind === "array" && type.valueType.kind === "model" (matching HLC's PropertyKind.Composite → no body wrapper). The unknown case now correctly keeps shouldWrap=true (PropertyKind.Primitive → wrapper with body).
|
|
||
| // Check if it's an unknown type (free-form object) | ||
| // These are returned as Record<string, unknown> directly to match HLC behavior | ||
| if (type.kind === "unknown") { |
There was a problem hiding this comment.
this would be impacted by our feature flag #3858.
by default unknown would be translated as any so shouldWrap would be false.
… behavior Co-authored-by: v-jiaodi <80496810+v-jiaodi@users.noreply.github.com> Agent-Logs-Url: https://github.com/Azure/autorest.typescript/sessions/714f6c94-fff2-443b-8808-af3cf523667a
wrap-non-model-return is enabledwrap-non-model-return is enabled
|
@copilot run |
…idget_dpg Co-authored-by: v-jiaodi <80496810+v-jiaodi@users.noreply.github.com> Agent-Logs-Url: https://github.com/Azure/autorest.typescript/sessions/c7ebfb7e-4f78-4ccc-b331-5968ed42635f
Done in commit 3dfa90c. Ran the smoke test and regenerated the affected generated files for
All smoke tests pass ("All specs succeeded!"). |
|
Should we include the Record case as well #3864? |
The Record is already included in existing cases, the above issue we notice is because we treat We have a fix #3869 to treat |
…Return Agent-Logs-Url: https://github.com/Azure/autorest.typescript/sessions/90664101-edd0-4d62-af61-9e9c6b6b722b Co-authored-by: MaryGao <9943211+MaryGao@users.noreply.github.com>
…b.com/Azure/autorest.typescript into copilot/migration-tsp-model-array-fix
… from main Regenerated 6 scenarios (NetworkAnalytics.Management, healthInsights_radiologyinsights, loadtesting_modular, nestedClient, openai_modular, schemaRegistry) that were affected by the merge with main branch (PR #3856: model array responses fix). This ensures the check:tree CI step passes. Agent-Logs-Url: https://github.com/Azure/autorest.typescript/sessions/47b50ca2-9eda-4d7f-8560-c906ba14c70f Co-authored-by: v-jiaodi <80496810+v-jiaodi@users.noreply.github.com>
…r leading-digit identifiers (#3868) * Initial plan * Fix enum member names: use enum type name as prefix instead of underscore" - Update emitEnumMember to accept enumTypeName parameter and use it as prefix instead of _ for invalid identifiers - Update buildEnumTypes to pass normalized enum type name to emitEnumMember - Update prefix-adding-in-enum-member diagnostic message format to include enumTypeName - Update enumKeyNorm.md scenario snapshot to use enum type name prefix - Update extends.md scenario snapshot with new enum member names - Update enumUnion.spec.ts test to properly verify new diagnostic behavior Co-authored-by: MaryGao <9943211+MaryGao@users.noreply.github.com> Agent-Logs-Url: https://github.com/Azure/autorest.typescript/sessions/99a3e736-bfc1-4400-a41d-56f4053c4638 * Refactor emitEnumMember for cleaner code structure after review Co-authored-by: MaryGao <9943211+MaryGao@users.noreply.github.com> Agent-Logs-Url: https://github.com/Azure/autorest.typescript/sessions/99a3e736-bfc1-4400-a41d-56f4053c4638 * Regenerate TypeSpec smoke test scenarios with new enum member naming Generated files updated to reflect the new enum member naming where enum type name is used as prefix instead of underscore (e.g., Versions100 instead of _100, Versions20240701Preview instead of _20240701Preview). This ensures the CI check:tree step passes since it compares generated files against committed files. Co-authored-by: MaryGao <9943211+MaryGao@users.noreply.github.com> Agent-Logs-Url: https://github.com/Azure/autorest.typescript/sessions/d16aef3a-466d-4251-a6fe-489bd3fd2549 * Restore and regenerate openai_non_branded TypeSpec test scenario The previous commit accidentally deleted the openai_non_branded generated files because it uses a non-standard tspconfig.yaml path (in spec/ not root). Re-running the smoke test properly regenerates these files. Co-authored-by: MaryGao <9943211+MaryGao@users.noreply.github.com> Agent-Logs-Url: https://github.com/Azure/autorest.typescript/sessions/d16aef3a-466d-4251-a6fe-489bd3fd2549 * Run pnpm smoke-test to regenerate TypeSpec test scenarios after merge from main Regenerated 6 scenarios (NetworkAnalytics.Management, healthInsights_radiologyinsights, loadtesting_modular, nestedClient, openai_modular, schemaRegistry) that were affected by the merge with main branch (PR #3856: model array responses fix). This ensures the check:tree CI step passes. Agent-Logs-Url: https://github.com/Azure/autorest.typescript/sessions/47b50ca2-9eda-4d7f-8560-c906ba14c70f Co-authored-by: v-jiaodi <80496810+v-jiaodi@users.noreply.github.com> * Refactor emitEnumMember: compute enumTypeName from member.enumType.name internally Agent-Logs-Url: https://github.com/Azure/autorest.typescript/sessions/4a41bf9d-0c14-444a-8f5e-2995bbcb3461 Co-authored-by: MaryGao <9943211+MaryGao@users.noreply.github.com> * Fix duplicate enum member names by adding numeric suffix when collision occurs Agent-Logs-Url: https://github.com/Azure/autorest.typescript/sessions/335fe4df-4788-4ba4-8c2a-079e2935ec43 Co-authored-by: MaryGao <9943211+MaryGao@users.noreply.github.com> * Revert headerParamWithClientInitialization.md and storageCompatResponse.md to original state Agent-Logs-Url: https://github.com/Azure/autorest.typescript/sessions/7e7b2568-202d-4eae-8fc3-c62f37697674 Co-authored-by: v-jiaodi <80496810+v-jiaodi@users.noreply.github.com> * Should not change when DO_NOT_NORMALIZE prefix --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: MaryGao <9943211+MaryGao@users.noreply.github.com> Co-authored-by: Jiao Di (MSFT) <80496810+v-jiaodi@users.noreply.github.com> Co-authored-by: Mary Gao <marygao@microsoft.com>
…ap-non-model-return` is enabled (Azure#3856) * Initial plan * fix: return model array responses as T[] directly to match HLC behavior Co-authored-by: v-jiaodi <80496810+v-jiaodi@users.noreply.github.com> * fix: return unknown responses as Record<string, unknown> to match HLC behavior Co-authored-by: v-jiaodi <80496810+v-jiaodi@users.noreply.github.com> * fix: generate Resource[] instead of (Resource)[] for model array response alias Co-authored-by: v-jiaodi <80496810+v-jiaodi@users.noreply.github.com> Agent-Logs-Url: https://github.com/Azure/autorest.typescript/sessions/6e436425-0256-49d0-8f11-05e4ff1ace61 * fix: update integration test specs for new direct response types (no .body wrapper) Co-authored-by: v-jiaodi <80496810+v-jiaodi@users.noreply.github.com> Agent-Logs-Url: https://github.com/Azure/autorest.typescript/sessions/1b0cb8e1-c52f-4dcb-a032-712f3d13d44d * fix: simplify type assertion in scalar spec to use strictEqual<unknown> Co-authored-by: v-jiaodi <80496810+v-jiaodi@users.noreply.github.com> Agent-Logs-Url: https://github.com/Azure/autorest.typescript/sessions/1b0cb8e1-c52f-4dcb-a032-712f3d13d44d * revert: remove spec-coverage.json and add to .gitignore Co-authored-by: v-jiaodi <80496810+v-jiaodi@users.noreply.github.com> Agent-Logs-Url: https://github.com/Azure/autorest.typescript/sessions/bf6a9e83-02c8-4bd2-afc7-4bfc90f6bc9a * revert: undo .gitignore change Co-authored-by: v-jiaodi <80496810+v-jiaodi@users.noreply.github.com> Agent-Logs-Url: https://github.com/Azure/autorest.typescript/sessions/28742408-c2e9-475b-bf3d-779187207397 * fix: adjust shouldWrap to return false for model arrays, matching HLC behavior Co-authored-by: v-jiaodi <80496810+v-jiaodi@users.noreply.github.com> Agent-Logs-Url: https://github.com/Azure/autorest.typescript/sessions/714f6c94-fff2-443b-8808-af3cf523667a * fix: regenerate smoke test generated files for parametrizedHost and widget_dpg Co-authored-by: v-jiaodi <80496810+v-jiaodi@users.noreply.github.com> Agent-Logs-Url: https://github.com/Azure/autorest.typescript/sessions/c7ebfb7e-4f78-4ccc-b331-5968ed42635f * refactor: add detailed HLC→modular case comments in checkWrapNonModelReturn Agent-Logs-Url: https://github.com/Azure/autorest.typescript/sessions/90664101-edd0-4d62-af61-9e9c6b6b722b Co-authored-by: MaryGao <9943211+MaryGao@users.noreply.github.com> * add ut --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: v-jiaodi <80496810+v-jiaodi@users.noreply.github.com> Co-authored-by: MaryGao <9943211+MaryGao@users.noreply.github.com> Co-authored-by: Jiao Di (MSFT) <v-jiaodi@microsoft.com>
shouldWrapto return false for model arrays (HLC PropertyKind.Composite → no wrapper)wrapNonModelReturn.mdarrayItemTypes.spec.ts,azureClientOverload.spec.ts).d.tsfilesparametrizedHostandwidget_dpggenerated TypeScript filescheckWrapNonModelReturndocumenting HLC→modular mappingsbody✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.