Change body to bodyroot in converter (#5032)

Co-authored-by: Pan Shao <pashao@microsoft.com>
This commit is contained in:
Pan Shao 2024-11-01 10:27:29 +08:00 коммит произвёл GitHub
Родитель 264b421ef4
Коммит 306c387fdd
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: B5690EEEBB952194
16 изменённых файлов: 32 добавлений и 22 удалений

Просмотреть файл

@ -0,0 +1,10 @@
{
"changes": [
{
"packageName": "@autorest/openapi-to-typespec",
"comment": "Change @body to @bodyRoot",
"type": "patch"
}
],
"packageName": "@autorest/openapi-to-typespec"
}

Просмотреть файл

@ -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}`);
}

Просмотреть файл

@ -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();

Просмотреть файл

@ -42,7 +42,7 @@ interface AnalysisServicesServersOperationGroup {
create is ArmResourceCreateOrReplaceAsync<
AnalysisServicesServer,
Response = ArmResourceCreatedResponse<AnalysisServicesServer> | ArmResourceUpdatedResponse<AnalysisServicesServer> | (ArmAcceptedLroResponse & {
@body _: AnalysisServicesServer;
@bodyRoot _: AnalysisServicesServer;
})
>;

Просмотреть файл

@ -64,7 +64,7 @@ interface Disks {
createOrUpdate is ArmResourceCreateOrReplaceAsync<
Disk,
Response = ArmResourceCreatedResponse<Disk> | ArmResourceUpdatedResponse<Disk> | (ArmAcceptedLroResponse & {
@body _: Disk;
@bodyRoot _: Disk;
})
>;

Просмотреть файл

@ -43,7 +43,7 @@ interface DiskAccesses {
createOrUpdate is ArmResourceCreateOrReplaceAsync<
DiskAccess,
Response = ArmResourceCreatedResponse<DiskAccess> | ArmResourceUpdatedResponse<DiskAccess> | (ArmAcceptedLroResponse & {
@body _: DiskAccess;
@bodyRoot _: DiskAccess;
})
>;

Просмотреть файл

@ -43,7 +43,7 @@ interface DiskEncryptionSets {
createOrUpdate is ArmResourceCreateOrReplaceAsync<
DiskEncryptionSet,
Response = ArmResourceCreatedResponse<DiskEncryptionSet> | ArmResourceUpdatedResponse<DiskEncryptionSet> | (ArmAcceptedLroResponse & {
@body _: DiskEncryptionSet;
@bodyRoot _: DiskEncryptionSet;
})
>;

Просмотреть файл

@ -52,7 +52,7 @@ interface Galleries {
createOrUpdate is ArmResourceCreateOrReplaceAsync<
Gallery,
Response = ArmResourceCreatedResponse<Gallery> | ArmResourceUpdatedResponse<Gallery> | (ArmAcceptedLroResponse & {
@body _: Gallery;
@bodyRoot _: Gallery;
})
>;

Просмотреть файл

@ -40,7 +40,7 @@ interface GalleryApplications {
createOrUpdate is ArmResourceCreateOrReplaceAsync<
GalleryApplication,
Response = ArmResourceCreatedResponse<GalleryApplication> | ArmResourceUpdatedResponse<GalleryApplication> | (ArmAcceptedLroResponse & {
@body _: GalleryApplication;
@bodyRoot _: GalleryApplication;
})
>;

Просмотреть файл

@ -49,7 +49,7 @@ interface GalleryApplicationVersions {
createOrUpdate is ArmResourceCreateOrReplaceAsync<
GalleryApplicationVersion,
Response = ArmResourceCreatedResponse<GalleryApplicationVersion> | ArmResourceUpdatedResponse<GalleryApplicationVersion> | (ArmAcceptedLroResponse & {
@body _: GalleryApplicationVersion;
@bodyRoot _: GalleryApplicationVersion;
})
>;

Просмотреть файл

@ -40,7 +40,7 @@ interface GalleryImages {
createOrUpdate is ArmResourceCreateOrReplaceAsync<
GalleryImage,
Response = ArmResourceCreatedResponse<GalleryImage> | ArmResourceUpdatedResponse<GalleryImage> | (ArmAcceptedLroResponse & {
@body _: GalleryImage;
@bodyRoot _: GalleryImage;
})
>;

Просмотреть файл

@ -49,7 +49,7 @@ interface GalleryImageVersions {
createOrUpdate is ArmResourceCreateOrReplaceAsync<
GalleryImageVersion,
Response = ArmResourceCreatedResponse<GalleryImageVersion> | ArmResourceUpdatedResponse<GalleryImageVersion> | (ArmAcceptedLroResponse & {
@body _: GalleryImageVersion;
@bodyRoot _: GalleryImageVersion;
})
>;

Просмотреть файл

@ -56,7 +56,7 @@ interface PrivateEndpointConnections {
updateAPrivateEndpointConnection is ArmResourceCreateOrReplaceAsync<
PrivateEndpointConnection,
Response = ArmResourceCreatedResponse<PrivateEndpointConnection> | ArmResourceUpdatedResponse<PrivateEndpointConnection> | (ArmAcceptedLroResponse & {
@body _: PrivateEndpointConnection;
@bodyRoot _: PrivateEndpointConnection;
})
>;

Просмотреть файл

@ -53,7 +53,7 @@ interface Snapshots {
createOrUpdate is ArmResourceCreateOrReplaceAsync<
Snapshot,
Response = ArmResourceCreatedResponse<Snapshot> | ArmResourceUpdatedResponse<Snapshot> | (ArmAcceptedLroResponse & {
@body _: Snapshot;
@bodyRoot _: Snapshot;
})
>;

Просмотреть файл

@ -87,7 +87,7 @@ interface VirtualMachineScaleSetVMS {
update is ArmResourceCreateOrReplaceAsync<
VirtualMachineScaleSetVM,
Response = ArmResourceCreatedResponse<VirtualMachineScaleSetVM> | ArmResourceUpdatedResponse<VirtualMachineScaleSetVM> | (ArmAcceptedLroResponse & {
@body _: VirtualMachineScaleSetVM;
@bodyRoot _: VirtualMachineScaleSetVM;
})
>;

Просмотреть файл

@ -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 = {