Skip to content

Commit

Permalink
Change body to bodyroot in converter (#5032)
Browse files Browse the repository at this point in the history
Co-authored-by: Pan Shao <pashao@microsoft.com>
  • Loading branch information
pshao25 and Pan Shao authored Nov 1, 2024
1 parent 264b421 commit 306c387
Show file tree
Hide file tree
Showing 16 changed files with 32 additions and 22 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"changes": [
{
"packageName": "@autorest/openapi-to-typespec",
"comment": "Change @body to @bodyRoot",
"type": "patch"
}
],
"packageName": "@autorest/openapi-to-typespec"
}
Original file line number Diff line number Diff line change
Expand Up @@ -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}`);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ interface AnalysisServicesServersOperationGroup {
create is ArmResourceCreateOrReplaceAsync<
AnalysisServicesServer,
Response = ArmResourceCreatedResponse<AnalysisServicesServer> | ArmResourceUpdatedResponse<AnalysisServicesServer> | (ArmAcceptedLroResponse & {
@body _: AnalysisServicesServer;
@bodyRoot _: AnalysisServicesServer;
})
>;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ interface Disks {
createOrUpdate is ArmResourceCreateOrReplaceAsync<
Disk,
Response = ArmResourceCreatedResponse<Disk> | ArmResourceUpdatedResponse<Disk> | (ArmAcceptedLroResponse & {
@body _: Disk;
@bodyRoot _: Disk;
})
>;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ interface DiskAccesses {
createOrUpdate is ArmResourceCreateOrReplaceAsync<
DiskAccess,
Response = ArmResourceCreatedResponse<DiskAccess> | ArmResourceUpdatedResponse<DiskAccess> | (ArmAcceptedLroResponse & {
@body _: DiskAccess;
@bodyRoot _: DiskAccess;
})
>;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ interface DiskEncryptionSets {
createOrUpdate is ArmResourceCreateOrReplaceAsync<
DiskEncryptionSet,
Response = ArmResourceCreatedResponse<DiskEncryptionSet> | ArmResourceUpdatedResponse<DiskEncryptionSet> | (ArmAcceptedLroResponse & {
@body _: DiskEncryptionSet;
@bodyRoot _: DiskEncryptionSet;
})
>;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ interface Galleries {
createOrUpdate is ArmResourceCreateOrReplaceAsync<
Gallery,
Response = ArmResourceCreatedResponse<Gallery> | ArmResourceUpdatedResponse<Gallery> | (ArmAcceptedLroResponse & {
@body _: Gallery;
@bodyRoot _: Gallery;
})
>;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ interface GalleryApplications {
createOrUpdate is ArmResourceCreateOrReplaceAsync<
GalleryApplication,
Response = ArmResourceCreatedResponse<GalleryApplication> | ArmResourceUpdatedResponse<GalleryApplication> | (ArmAcceptedLroResponse & {
@body _: GalleryApplication;
@bodyRoot _: GalleryApplication;
})
>;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ interface GalleryApplicationVersions {
createOrUpdate is ArmResourceCreateOrReplaceAsync<
GalleryApplicationVersion,
Response = ArmResourceCreatedResponse<GalleryApplicationVersion> | ArmResourceUpdatedResponse<GalleryApplicationVersion> | (ArmAcceptedLroResponse & {
@body _: GalleryApplicationVersion;
@bodyRoot _: GalleryApplicationVersion;
})
>;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ interface GalleryImages {
createOrUpdate is ArmResourceCreateOrReplaceAsync<
GalleryImage,
Response = ArmResourceCreatedResponse<GalleryImage> | ArmResourceUpdatedResponse<GalleryImage> | (ArmAcceptedLroResponse & {
@body _: GalleryImage;
@bodyRoot _: GalleryImage;
})
>;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ interface GalleryImageVersions {
createOrUpdate is ArmResourceCreateOrReplaceAsync<
GalleryImageVersion,
Response = ArmResourceCreatedResponse<GalleryImageVersion> | ArmResourceUpdatedResponse<GalleryImageVersion> | (ArmAcceptedLroResponse & {
@body _: GalleryImageVersion;
@bodyRoot _: GalleryImageVersion;
})
>;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ interface PrivateEndpointConnections {
updateAPrivateEndpointConnection is ArmResourceCreateOrReplaceAsync<
PrivateEndpointConnection,
Response = ArmResourceCreatedResponse<PrivateEndpointConnection> | ArmResourceUpdatedResponse<PrivateEndpointConnection> | (ArmAcceptedLroResponse & {
@body _: PrivateEndpointConnection;
@bodyRoot _: PrivateEndpointConnection;
})
>;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ interface Snapshots {
createOrUpdate is ArmResourceCreateOrReplaceAsync<
Snapshot,
Response = ArmResourceCreatedResponse<Snapshot> | ArmResourceUpdatedResponse<Snapshot> | (ArmAcceptedLroResponse & {
@body _: Snapshot;
@bodyRoot _: Snapshot;
})
>;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ interface VirtualMachineScaleSetVMS {
update is ArmResourceCreateOrReplaceAsync<
VirtualMachineScaleSetVM,
Response = ArmResourceCreatedResponse<VirtualMachineScaleSetVM> | ArmResourceUpdatedResponse<VirtualMachineScaleSetVM> | (ArmAcceptedLroResponse & {
@body _: VirtualMachineScaleSetVM;
@bodyRoot _: VirtualMachineScaleSetVM;
})
>;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ interface VirtualMachineImagesOperations {
@action("versions")
list is ArmProviderActionAsync<
Response = {
@body _: VirtualMachineImageResource[];
@bodyRoot _: VirtualMachineImageResource[];
},
Scope = SubscriptionActionScope,
Parameters = {
Expand Down Expand Up @@ -177,7 +177,7 @@ interface VirtualMachineImagesOperations {
@action("artifacttypes/vmimage/offers")
listOffers is ArmProviderActionAsync<
Response = {
@body _: VirtualMachineImageResource[];
@bodyRoot _: VirtualMachineImageResource[];
},
Scope = SubscriptionActionScope,
Parameters = {
Expand All @@ -200,7 +200,7 @@ interface VirtualMachineImagesOperations {
@action("publishers")
listPublishers is ArmProviderActionAsync<
Response = {
@body _: VirtualMachineImageResource[];
@bodyRoot _: VirtualMachineImageResource[];
},
Scope = SubscriptionActionScope,
Parameters = LocationParameter
Expand All @@ -214,7 +214,7 @@ interface VirtualMachineImagesOperations {
@action("skus")
listSkus is ArmProviderActionAsync<
Response = {
@body _: VirtualMachineImageResource[];
@bodyRoot _: VirtualMachineImageResource[];
},
Scope = SubscriptionActionScope,
Parameters = {
Expand Down Expand Up @@ -313,7 +313,7 @@ interface VirtualMachineImagesEdgeZoneOperations {
@action("versions")
list is ArmProviderActionAsync<
Response = {
@body _: VirtualMachineImageResource[];
@bodyRoot _: VirtualMachineImageResource[];
},
Scope = SubscriptionActionScope,
Parameters = {
Expand Down Expand Up @@ -375,7 +375,7 @@ interface VirtualMachineImagesEdgeZoneOperations {
@action("artifacttypes/vmimage/offers")
listOffers is ArmProviderActionAsync<
Response = {
@body _: VirtualMachineImageResource[];
@bodyRoot _: VirtualMachineImageResource[];
},
Scope = SubscriptionActionScope,
Parameters = {
Expand Down Expand Up @@ -405,7 +405,7 @@ interface VirtualMachineImagesEdgeZoneOperations {
@action("publishers")
listPublishers is ArmProviderActionAsync<
Response = {
@body _: VirtualMachineImageResource[];
@bodyRoot _: VirtualMachineImageResource[];
},
Scope = SubscriptionActionScope,
Parameters = {
Expand All @@ -428,7 +428,7 @@ interface VirtualMachineImagesEdgeZoneOperations {
@action("skus")
listSkus is ArmProviderActionAsync<
Response = {
@body _: VirtualMachineImageResource[];
@bodyRoot _: VirtualMachineImageResource[];
},
Scope = SubscriptionActionScope,
Parameters = {
Expand Down

0 comments on commit 306c387

Please sign in to comment.