Skip to content

Commit 16b2811

Browse files
authored
Conditionally force array context when converting to JSON (#19262)
1 parent d12cc0b commit 16b2811

File tree

2 files changed

+7
-2
lines changed
  • modules/openapi-generator/src/main/resources/powershell
  • samples/client/petstore/powershell/src/PSPetstore/Api

2 files changed

+7
-2
lines changed

modules/openapi-generator/src/main/resources/powershell/api.mustache

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,12 @@ function {{{vendorExtensions.x-powershell-method-name}}} {
172172

173173
{{/isNullable}}
174174
{{/required}}
175+
{{#isArray}}
176+
$LocalVarBodyParameter = ,${{{paramName}}} | ConvertTo-Json -Depth 100
177+
{{/isArray}}
178+
{{^isArray}}
175179
$LocalVarBodyParameter = ${{{paramName}}} | ConvertTo-Json -Depth 100
180+
{{/isArray}}
176181

177182
{{/bodyParam}}
178183
{{#authMethods}}

samples/client/petstore/powershell/src/PSPetstore/Api/PSUserApi.ps1

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ function New-PSUsersWithArrayInput {
133133
throw "Error! The required parameter `User` missing when calling createUsersWithArrayInput."
134134
}
135135

136-
$LocalVarBodyParameter = $User | ConvertTo-Json -Depth 100
136+
$LocalVarBodyParameter = ,$User | ConvertTo-Json -Depth 100
137137

138138
$LocalVarResult = Invoke-PSApiClient -Method 'POST' `
139139
-Uri $LocalVarUri `
@@ -208,7 +208,7 @@ function New-PSUsersWithListInput {
208208
throw "Error! The required parameter `User` missing when calling createUsersWithListInput."
209209
}
210210

211-
$LocalVarBodyParameter = $User | ConvertTo-Json -Depth 100
211+
$LocalVarBodyParameter = ,$User | ConvertTo-Json -Depth 100
212212

213213
$LocalVarResult = Invoke-PSApiClient -Method 'POST' `
214214
-Uri $LocalVarUri `

0 commit comments

Comments
 (0)