From a26798adc2a398ee994db655d0aa2d45a96ca449 Mon Sep 17 00:00:00 2001 From: William Cheng Date: Mon, 7 Jun 2021 10:22:45 +0800 Subject: [PATCH] null check on $ContentTypes --- .../src/main/resources/powershell/api_client.mustache | 4 ++++ .../powershell/src/PSPetstore/Private/PSApiClient.ps1 | 4 ++++ 2 files changed, 8 insertions(+) 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