From 37b7c80c4f9b45223657fcc85c3fa3a002f54121 Mon Sep 17 00:00:00 2001 From: William Cheng Date: Tue, 8 Jun 2021 09:09:21 +0800 Subject: [PATCH] null check on $ContentTypes (#9687) --- .../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 b17371ad1e3..7d45f071b1e 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 9223b3a93e6..09a202cee9d 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