From ac85891f5170cab71649c36924a703a64a04a173 Mon Sep 17 00:00:00 2001 From: Xiaogang Date: Tue, 12 Nov 2024 14:10:12 +0800 Subject: [PATCH] Fixed a group parameter related issue (#1402) --- powershell/plugins/sdk-cs-namer.ts | 4 +++- powershell/resources/templates/methodBodyRestCall.ejs | 2 +- .../Sphere.Management/target/generate-portal-ux.ps1 | 9 +++++++++ 3 files changed, 13 insertions(+), 2 deletions(-) diff --git a/powershell/plugins/sdk-cs-namer.ts b/powershell/plugins/sdk-cs-namer.ts index 5444f31f31..e06ce23e14 100644 --- a/powershell/plugins/sdk-cs-namer.ts +++ b/powershell/plugins/sdk-cs-namer.ts @@ -404,7 +404,9 @@ function correctParameterNames(model: SdkModel) { for (const operationGroup of model.operationGroups) { for (const operation of operationGroup.operations) { for (const parameter of values(operation.parameters)) { - parameter.language.default.name = getEscapedReservedName(parameter.language.default.name, 'Parameter'); + // Use suffix 'property' for parameters in parameter group since we use 'property' for schema names + const suffix = parameter.extensions && parameter.extensions['x-ms-parameter-grouping'] ? 'Property' : 'Parameter'; + parameter.language.default.name = getEscapedReservedName(parameter.language.default.name, suffix); } if (operation.requests) { // body parameters diff --git a/powershell/resources/templates/methodBodyRestCall.ejs b/powershell/resources/templates/methodBodyRestCall.ejs index 45267de7b7..be1801a598 100644 --- a/powershell/resources/templates/methodBodyRestCall.ejs +++ b/powershell/resources/templates/methodBodyRestCall.ejs @@ -47,7 +47,7 @@ if (method.extensions && method.extensions['x-ms-request-id']) { } <% } -%> <%# for odata, validation is not needed. -%> -<%- parameter.extensions && parameter.extensions['x-ms-odata'] ? '' : project.helper.ValidateType(parameter.schema, method, prefix + parameter.language.default.name, parameter.nullable != false)%> +<%- parameter.extensions && (parameter.extensions['x-ms-odata'] || parameter.extensions['x-ms-parameter-grouping']) ? '' : project.helper.ValidateType(parameter.schema, method, prefix + parameter.language.default.name, parameter.nullable != false)%> <%});}-%> <%(method.parameters || []).filter(p => p.protocol.http.in == 'complex').forEach(function(parameter) {-%> <%-project.helper.PopulateGroupParameters(parameter)%> diff --git a/tests-upgrade/tests-emitter/Sphere.Management/target/generate-portal-ux.ps1 b/tests-upgrade/tests-emitter/Sphere.Management/target/generate-portal-ux.ps1 index 1953ce043a..970bcfd3ca 100644 --- a/tests-upgrade/tests-emitter/Sphere.Management/target/generate-portal-ux.ps1 +++ b/tests-upgrade/tests-emitter/Sphere.Management/target/generate-portal-ux.ps1 @@ -247,7 +247,16 @@ function New-MetadataForParameterSet() $cmdletName = Get-MappedCmdletFromFunctionName $ParameterSetInfo.Name $description = (Get-CmdletAttribute -CmdletInfo $ParameterSetInfo -AttributeName "DescriptionAttribute").Description [object[]]$example = New-ExampleForParameterSet $ParameterSetInfo + if ($Null -eq $example) + { + $example = @() + } + [string[]]$signature = New-ParameterArrayInParameterSet $ParameterSetInfo + if ($Null -eq $signature) + { + $signature = @() + } return @{ Path = $httpPath