From 97770d46a30fe549243c5c514d8ce85804fd5d67 Mon Sep 17 00:00:00 2001 From: Pan Shao <pashao@microsoft.com> Date: Thu, 24 Oct 2024 19:56:17 +0800 Subject: [PATCH 1/2] Change body to bodyroot --- .../src/generate/generate-operations.ts | 2 +- .../src/transforms/transform-arm-resources.ts | 2 +- .../tsp-output/AnalysisServicesServer.tsp | 2 +- .../test/arm-compute/tsp-output/Disk.tsp | 2 +- .../test/arm-compute/tsp-output/DiskAccess.tsp | 2 +- .../arm-compute/tsp-output/DiskEncryptionSet.tsp | 2 +- .../test/arm-compute/tsp-output/Gallery.tsp | 2 +- .../tsp-output/GalleryApplication.tsp | 2 +- .../tsp-output/GalleryApplicationVersion.tsp | 2 +- .../test/arm-compute/tsp-output/GalleryImage.tsp | 2 +- .../tsp-output/GalleryImageVersion.tsp | 2 +- .../tsp-output/PrivateEndpointConnection.tsp | 2 +- .../test/arm-compute/tsp-output/Snapshot.tsp | 2 +- .../tsp-output/VirtualMachineScaleSetVM.tsp | 2 +- .../test/arm-compute/tsp-output/routes.tsp | 16 ++++++++-------- 15 files changed, 22 insertions(+), 22 deletions(-) diff --git a/packages/extensions/openapi-to-typespec/src/generate/generate-operations.ts b/packages/extensions/openapi-to-typespec/src/generate/generate-operations.ts index ff2bde24bf..633693c0c3 100644 --- a/packages/extensions/openapi-to-typespec/src/generate/generate-operations.ts +++ b/packages/extensions/openapi-to-typespec/src/generate/generate-operations.ts @@ -81,7 +81,7 @@ export function generateProviderAction(operation: TspArmProviderActionOperation) const responses = [...new Set(operation.responses)]; // Workaround for array response, refactor later. const response = - responses.length === 1 && responses[0].endsWith("[]") ? `{@body _: ${responses[0]}}` : responses.join("|"); + responses.length === 1 && responses[0].endsWith("[]") ? `{@bodyRoot _: ${responses[0]}}` : responses.join("|"); if (response !== "void") { templateParameters.push(`Response = ${response}`); } diff --git a/packages/extensions/openapi-to-typespec/src/transforms/transform-arm-resources.ts b/packages/extensions/openapi-to-typespec/src/transforms/transform-arm-resources.ts index 804a83b138..712c071f3b 100644 --- a/packages/extensions/openapi-to-typespec/src/transforms/transform-arm-resources.ts +++ b/packages/extensions/openapi-to-typespec/src/transforms/transform-arm-resources.ts @@ -310,7 +310,7 @@ function convertResourceCreateOrReplaceOperation( if (acceptedResponse) { let responseParameter = `ArmResourceCreatedResponse<${resourceMetadata.SwaggerModelName}> | ArmResourceUpdatedResponse<${resourceMetadata.SwaggerModelName}>`; if (isResponseSchema(acceptedResponse) && acceptedResponse.schema) { - responseParameter += `| (ArmAcceptedLroResponse & {@body _: ${resourceMetadata.SwaggerModelName};})`; + responseParameter += `| (ArmAcceptedLroResponse & {@bodyRoot _: ${resourceMetadata.SwaggerModelName};})`; } else responseParameter += `| ArmAcceptedLroResponse`; templateParameters.push(`Response = ${responseParameter}`); suppressions = getSuppressionsForArmResourceCreateOrReplaceAsync(); diff --git a/packages/extensions/openapi-to-typespec/test/arm-analysisservices/tsp-output/AnalysisServicesServer.tsp b/packages/extensions/openapi-to-typespec/test/arm-analysisservices/tsp-output/AnalysisServicesServer.tsp index 908db7a5af..b6fc91bcc1 100644 --- a/packages/extensions/openapi-to-typespec/test/arm-analysisservices/tsp-output/AnalysisServicesServer.tsp +++ b/packages/extensions/openapi-to-typespec/test/arm-analysisservices/tsp-output/AnalysisServicesServer.tsp @@ -42,7 +42,7 @@ interface AnalysisServicesServersOperationGroup { create is ArmResourceCreateOrReplaceAsync< AnalysisServicesServer, Response = ArmResourceCreatedResponse<AnalysisServicesServer> | ArmResourceUpdatedResponse<AnalysisServicesServer> | (ArmAcceptedLroResponse & { - @body _: AnalysisServicesServer; + @bodyRoot _: AnalysisServicesServer; }) >; diff --git a/packages/extensions/openapi-to-typespec/test/arm-compute/tsp-output/Disk.tsp b/packages/extensions/openapi-to-typespec/test/arm-compute/tsp-output/Disk.tsp index 67a42713c5..3cb3c32747 100644 --- a/packages/extensions/openapi-to-typespec/test/arm-compute/tsp-output/Disk.tsp +++ b/packages/extensions/openapi-to-typespec/test/arm-compute/tsp-output/Disk.tsp @@ -64,7 +64,7 @@ interface Disks { createOrUpdate is ArmResourceCreateOrReplaceAsync< Disk, Response = ArmResourceCreatedResponse<Disk> | ArmResourceUpdatedResponse<Disk> | (ArmAcceptedLroResponse & { - @body _: Disk; + @bodyRoot _: Disk; }) >; diff --git a/packages/extensions/openapi-to-typespec/test/arm-compute/tsp-output/DiskAccess.tsp b/packages/extensions/openapi-to-typespec/test/arm-compute/tsp-output/DiskAccess.tsp index 8d76c5805f..e04e445308 100644 --- a/packages/extensions/openapi-to-typespec/test/arm-compute/tsp-output/DiskAccess.tsp +++ b/packages/extensions/openapi-to-typespec/test/arm-compute/tsp-output/DiskAccess.tsp @@ -43,7 +43,7 @@ interface DiskAccesses { createOrUpdate is ArmResourceCreateOrReplaceAsync< DiskAccess, Response = ArmResourceCreatedResponse<DiskAccess> | ArmResourceUpdatedResponse<DiskAccess> | (ArmAcceptedLroResponse & { - @body _: DiskAccess; + @bodyRoot _: DiskAccess; }) >; diff --git a/packages/extensions/openapi-to-typespec/test/arm-compute/tsp-output/DiskEncryptionSet.tsp b/packages/extensions/openapi-to-typespec/test/arm-compute/tsp-output/DiskEncryptionSet.tsp index d98ffeb847..9cf9505900 100644 --- a/packages/extensions/openapi-to-typespec/test/arm-compute/tsp-output/DiskEncryptionSet.tsp +++ b/packages/extensions/openapi-to-typespec/test/arm-compute/tsp-output/DiskEncryptionSet.tsp @@ -43,7 +43,7 @@ interface DiskEncryptionSets { createOrUpdate is ArmResourceCreateOrReplaceAsync< DiskEncryptionSet, Response = ArmResourceCreatedResponse<DiskEncryptionSet> | ArmResourceUpdatedResponse<DiskEncryptionSet> | (ArmAcceptedLroResponse & { - @body _: DiskEncryptionSet; + @bodyRoot _: DiskEncryptionSet; }) >; diff --git a/packages/extensions/openapi-to-typespec/test/arm-compute/tsp-output/Gallery.tsp b/packages/extensions/openapi-to-typespec/test/arm-compute/tsp-output/Gallery.tsp index ec3dcbd4b1..abdf63675c 100644 --- a/packages/extensions/openapi-to-typespec/test/arm-compute/tsp-output/Gallery.tsp +++ b/packages/extensions/openapi-to-typespec/test/arm-compute/tsp-output/Gallery.tsp @@ -52,7 +52,7 @@ interface Galleries { createOrUpdate is ArmResourceCreateOrReplaceAsync< Gallery, Response = ArmResourceCreatedResponse<Gallery> | ArmResourceUpdatedResponse<Gallery> | (ArmAcceptedLroResponse & { - @body _: Gallery; + @bodyRoot _: Gallery; }) >; diff --git a/packages/extensions/openapi-to-typespec/test/arm-compute/tsp-output/GalleryApplication.tsp b/packages/extensions/openapi-to-typespec/test/arm-compute/tsp-output/GalleryApplication.tsp index 44575ceebf..7da394a558 100644 --- a/packages/extensions/openapi-to-typespec/test/arm-compute/tsp-output/GalleryApplication.tsp +++ b/packages/extensions/openapi-to-typespec/test/arm-compute/tsp-output/GalleryApplication.tsp @@ -40,7 +40,7 @@ interface GalleryApplications { createOrUpdate is ArmResourceCreateOrReplaceAsync< GalleryApplication, Response = ArmResourceCreatedResponse<GalleryApplication> | ArmResourceUpdatedResponse<GalleryApplication> | (ArmAcceptedLroResponse & { - @body _: GalleryApplication; + @bodyRoot _: GalleryApplication; }) >; diff --git a/packages/extensions/openapi-to-typespec/test/arm-compute/tsp-output/GalleryApplicationVersion.tsp b/packages/extensions/openapi-to-typespec/test/arm-compute/tsp-output/GalleryApplicationVersion.tsp index 46b8f76335..6c48666a53 100644 --- a/packages/extensions/openapi-to-typespec/test/arm-compute/tsp-output/GalleryApplicationVersion.tsp +++ b/packages/extensions/openapi-to-typespec/test/arm-compute/tsp-output/GalleryApplicationVersion.tsp @@ -49,7 +49,7 @@ interface GalleryApplicationVersions { createOrUpdate is ArmResourceCreateOrReplaceAsync< GalleryApplicationVersion, Response = ArmResourceCreatedResponse<GalleryApplicationVersion> | ArmResourceUpdatedResponse<GalleryApplicationVersion> | (ArmAcceptedLroResponse & { - @body _: GalleryApplicationVersion; + @bodyRoot _: GalleryApplicationVersion; }) >; diff --git a/packages/extensions/openapi-to-typespec/test/arm-compute/tsp-output/GalleryImage.tsp b/packages/extensions/openapi-to-typespec/test/arm-compute/tsp-output/GalleryImage.tsp index 7fcd78e855..124740b1e2 100644 --- a/packages/extensions/openapi-to-typespec/test/arm-compute/tsp-output/GalleryImage.tsp +++ b/packages/extensions/openapi-to-typespec/test/arm-compute/tsp-output/GalleryImage.tsp @@ -40,7 +40,7 @@ interface GalleryImages { createOrUpdate is ArmResourceCreateOrReplaceAsync< GalleryImage, Response = ArmResourceCreatedResponse<GalleryImage> | ArmResourceUpdatedResponse<GalleryImage> | (ArmAcceptedLroResponse & { - @body _: GalleryImage; + @bodyRoot _: GalleryImage; }) >; diff --git a/packages/extensions/openapi-to-typespec/test/arm-compute/tsp-output/GalleryImageVersion.tsp b/packages/extensions/openapi-to-typespec/test/arm-compute/tsp-output/GalleryImageVersion.tsp index a68c8efa34..5b68407884 100644 --- a/packages/extensions/openapi-to-typespec/test/arm-compute/tsp-output/GalleryImageVersion.tsp +++ b/packages/extensions/openapi-to-typespec/test/arm-compute/tsp-output/GalleryImageVersion.tsp @@ -49,7 +49,7 @@ interface GalleryImageVersions { createOrUpdate is ArmResourceCreateOrReplaceAsync< GalleryImageVersion, Response = ArmResourceCreatedResponse<GalleryImageVersion> | ArmResourceUpdatedResponse<GalleryImageVersion> | (ArmAcceptedLroResponse & { - @body _: GalleryImageVersion; + @bodyRoot _: GalleryImageVersion; }) >; diff --git a/packages/extensions/openapi-to-typespec/test/arm-compute/tsp-output/PrivateEndpointConnection.tsp b/packages/extensions/openapi-to-typespec/test/arm-compute/tsp-output/PrivateEndpointConnection.tsp index e895982427..a5435ea896 100644 --- a/packages/extensions/openapi-to-typespec/test/arm-compute/tsp-output/PrivateEndpointConnection.tsp +++ b/packages/extensions/openapi-to-typespec/test/arm-compute/tsp-output/PrivateEndpointConnection.tsp @@ -56,7 +56,7 @@ interface PrivateEndpointConnections { updateAPrivateEndpointConnection is ArmResourceCreateOrReplaceAsync< PrivateEndpointConnection, Response = ArmResourceCreatedResponse<PrivateEndpointConnection> | ArmResourceUpdatedResponse<PrivateEndpointConnection> | (ArmAcceptedLroResponse & { - @body _: PrivateEndpointConnection; + @bodyRoot _: PrivateEndpointConnection; }) >; diff --git a/packages/extensions/openapi-to-typespec/test/arm-compute/tsp-output/Snapshot.tsp b/packages/extensions/openapi-to-typespec/test/arm-compute/tsp-output/Snapshot.tsp index a941af0266..dd95da6a50 100644 --- a/packages/extensions/openapi-to-typespec/test/arm-compute/tsp-output/Snapshot.tsp +++ b/packages/extensions/openapi-to-typespec/test/arm-compute/tsp-output/Snapshot.tsp @@ -53,7 +53,7 @@ interface Snapshots { createOrUpdate is ArmResourceCreateOrReplaceAsync< Snapshot, Response = ArmResourceCreatedResponse<Snapshot> | ArmResourceUpdatedResponse<Snapshot> | (ArmAcceptedLroResponse & { - @body _: Snapshot; + @bodyRoot _: Snapshot; }) >; diff --git a/packages/extensions/openapi-to-typespec/test/arm-compute/tsp-output/VirtualMachineScaleSetVM.tsp b/packages/extensions/openapi-to-typespec/test/arm-compute/tsp-output/VirtualMachineScaleSetVM.tsp index d46d06dbbd..2fa4a2081e 100644 --- a/packages/extensions/openapi-to-typespec/test/arm-compute/tsp-output/VirtualMachineScaleSetVM.tsp +++ b/packages/extensions/openapi-to-typespec/test/arm-compute/tsp-output/VirtualMachineScaleSetVM.tsp @@ -87,7 +87,7 @@ interface VirtualMachineScaleSetVMS { update is ArmResourceCreateOrReplaceAsync< VirtualMachineScaleSetVM, Response = ArmResourceCreatedResponse<VirtualMachineScaleSetVM> | ArmResourceUpdatedResponse<VirtualMachineScaleSetVM> | (ArmAcceptedLroResponse & { - @body _: VirtualMachineScaleSetVM; + @bodyRoot _: VirtualMachineScaleSetVM; }) >; diff --git a/packages/extensions/openapi-to-typespec/test/arm-compute/tsp-output/routes.tsp b/packages/extensions/openapi-to-typespec/test/arm-compute/tsp-output/routes.tsp index ed0bbf3841..2fbcf20878 100644 --- a/packages/extensions/openapi-to-typespec/test/arm-compute/tsp-output/routes.tsp +++ b/packages/extensions/openapi-to-typespec/test/arm-compute/tsp-output/routes.tsp @@ -126,7 +126,7 @@ interface VirtualMachineImagesOperations { @action("versions") list is ArmProviderActionAsync< Response = { - @body _: VirtualMachineImageResource[]; + @bodyRoot _: VirtualMachineImageResource[]; }, Scope = SubscriptionActionScope, Parameters = { @@ -177,7 +177,7 @@ interface VirtualMachineImagesOperations { @action("artifacttypes/vmimage/offers") listOffers is ArmProviderActionAsync< Response = { - @body _: VirtualMachineImageResource[]; + @bodyRoot _: VirtualMachineImageResource[]; }, Scope = SubscriptionActionScope, Parameters = { @@ -200,7 +200,7 @@ interface VirtualMachineImagesOperations { @action("publishers") listPublishers is ArmProviderActionAsync< Response = { - @body _: VirtualMachineImageResource[]; + @bodyRoot _: VirtualMachineImageResource[]; }, Scope = SubscriptionActionScope, Parameters = LocationParameter @@ -214,7 +214,7 @@ interface VirtualMachineImagesOperations { @action("skus") listSkus is ArmProviderActionAsync< Response = { - @body _: VirtualMachineImageResource[]; + @bodyRoot _: VirtualMachineImageResource[]; }, Scope = SubscriptionActionScope, Parameters = { @@ -313,7 +313,7 @@ interface VirtualMachineImagesEdgeZoneOperations { @action("versions") list is ArmProviderActionAsync< Response = { - @body _: VirtualMachineImageResource[]; + @bodyRoot _: VirtualMachineImageResource[]; }, Scope = SubscriptionActionScope, Parameters = { @@ -375,7 +375,7 @@ interface VirtualMachineImagesEdgeZoneOperations { @action("artifacttypes/vmimage/offers") listOffers is ArmProviderActionAsync< Response = { - @body _: VirtualMachineImageResource[]; + @bodyRoot _: VirtualMachineImageResource[]; }, Scope = SubscriptionActionScope, Parameters = { @@ -405,7 +405,7 @@ interface VirtualMachineImagesEdgeZoneOperations { @action("publishers") listPublishers is ArmProviderActionAsync< Response = { - @body _: VirtualMachineImageResource[]; + @bodyRoot _: VirtualMachineImageResource[]; }, Scope = SubscriptionActionScope, Parameters = { @@ -428,7 +428,7 @@ interface VirtualMachineImagesEdgeZoneOperations { @action("skus") listSkus is ArmProviderActionAsync< Response = { - @body _: VirtualMachineImageResource[]; + @bodyRoot _: VirtualMachineImageResource[]; }, Scope = SubscriptionActionScope, Parameters = { From 962c1ac98271e0fe5a0786e89b6d2bd1406d6e7f Mon Sep 17 00:00:00 2001 From: Pan Shao <pashao@microsoft.com> Date: Thu, 24 Oct 2024 19:58:06 +0800 Subject: [PATCH 2/2] update --- .../bodyrootFix_2024-10-24-11-57.json | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100644 common/changes/@autorest/openapi-to-typespec/bodyrootFix_2024-10-24-11-57.json diff --git a/common/changes/@autorest/openapi-to-typespec/bodyrootFix_2024-10-24-11-57.json b/common/changes/@autorest/openapi-to-typespec/bodyrootFix_2024-10-24-11-57.json new file mode 100644 index 0000000000..b80a880f5a --- /dev/null +++ b/common/changes/@autorest/openapi-to-typespec/bodyrootFix_2024-10-24-11-57.json @@ -0,0 +1,10 @@ +{ + "changes": [ + { + "packageName": "@autorest/openapi-to-typespec", + "comment": "Change @body to @bodyRoot", + "type": "patch" + } + ], + "packageName": "@autorest/openapi-to-typespec" +} \ No newline at end of file