diff --git a/modules/openapi-generator/src/main/resources/powershell/api_client.mustache b/modules/openapi-generator/src/main/resources/powershell/api_client.mustache index b17371ad1e37..7d45f071b1e6 100644 --- a/modules/openapi-generator/src/main/resources/powershell/api_client.mustache +++ b/modules/openapi-generator/src/main/resources/powershell/api_client.mustache @@ -211,6 +211,10 @@ function DeserializeResponse { [string[]]$ContentTypes ) + If ($ContentTypes -eq $null) { + $ContentTypes = [string[]]@() + } + If ([string]::IsNullOrEmpty($ReturnType) -and $ContentTypes.Count -eq 0) { # void response return $Response } Elseif ($ReturnType -match '\[\]$') { # array diff --git a/samples/client/petstore/powershell/src/PSPetstore/Private/PSApiClient.ps1 b/samples/client/petstore/powershell/src/PSPetstore/Private/PSApiClient.ps1 index 9223b3a93e61..09a202cee9df 100644 --- a/samples/client/petstore/powershell/src/PSPetstore/Private/PSApiClient.ps1 +++ b/samples/client/petstore/powershell/src/PSPetstore/Private/PSApiClient.ps1 @@ -198,6 +198,10 @@ function DeserializeResponse { [string[]]$ContentTypes ) + If ($ContentTypes -eq $null) { + $ContentTypes = [string[]]@() + } + If ([string]::IsNullOrEmpty($ReturnType) -and $ContentTypes.Count -eq 0) { # void response return $Response } Elseif ($ReturnType -match '\[\]$') { # array