From de081e4edf0e84ed0c4903fff6f952a3e6909e59 Mon Sep 17 00:00:00 2001 From: condorcorde <49915099+condorcorde@users.noreply.github.com> Date: Wed, 20 Mar 2024 05:53:58 +0100 Subject: [PATCH] Fix proxy type (#18166) * Update configuration.mustache Fix check of proxy type * Changing sample source files --- .../src/main/resources/powershell/configuration.mustache | 4 ++-- .../powershell/src/PSOpenAPITools/Client/Configuration.ps1 | 4 ++-- .../powershell/src/PSPetstore/Client/PSConfiguration.ps1 | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/modules/openapi-generator/src/main/resources/powershell/configuration.mustache b/modules/openapi-generator/src/main/resources/powershell/configuration.mustache index 0e674f1f56..ffc9ca50d0 100644 --- a/modules/openapi-generator/src/main/resources/powershell/configuration.mustache +++ b/modules/openapi-generator/src/main/resources/powershell/configuration.mustache @@ -173,8 +173,8 @@ function Set-{{{apiNamePrefix}}}Configuration { } If ($null -ne $Proxy) { - If ($Proxy.GetType().FullName -ne "System.Net.SystemWebProxy" -and $Proxy.GetType().FullName -ne "System.Net.WebRequest+WebProxyWrapperOpaque") { - throw "Incorrect Proxy type '$($Proxy.GetType().FullName)'. Must be System.Net.SystemWebProxy or System.Net.WebRequest+WebProxyWrapperOpaque." + If ('System.Net.IWebProxy' -notin $Proxy.GetType().ImplementedInterfaces.FullName) { + throw "Incorrect Proxy type '$($Proxy.GetType().FullName)'. Must implement System.Net.IWebProxy interface." } $Script:Configuration['Proxy'] = $Proxy } else { diff --git a/samples/client/echo_api/powershell/src/PSOpenAPITools/Client/Configuration.ps1 b/samples/client/echo_api/powershell/src/PSOpenAPITools/Client/Configuration.ps1 index 9e1aa107bb..baf8dbe0fd 100644 --- a/samples/client/echo_api/powershell/src/PSOpenAPITools/Client/Configuration.ps1 +++ b/samples/client/echo_api/powershell/src/PSOpenAPITools/Client/Configuration.ps1 @@ -180,8 +180,8 @@ function Set-Configuration { } If ($null -ne $Proxy) { - If ($Proxy.GetType().FullName -ne "System.Net.SystemWebProxy" -and $Proxy.GetType().FullName -ne "System.Net.WebRequest+WebProxyWrapperOpaque") { - throw "Incorrect Proxy type '$($Proxy.GetType().FullName)'. Must be System.Net.SystemWebProxy or System.Net.WebRequest+WebProxyWrapperOpaque." + If ('System.Net.IWebProxy' -notin $Proxy.GetType().ImplementedInterfaces.FullName) { + throw "Incorrect Proxy type '$($Proxy.GetType().FullName)'. Must implement System.Net.IWebProxy interface." } $Script:Configuration['Proxy'] = $Proxy } else { diff --git a/samples/client/petstore/powershell/src/PSPetstore/Client/PSConfiguration.ps1 b/samples/client/petstore/powershell/src/PSPetstore/Client/PSConfiguration.ps1 index d655e6f997..043b2f9e84 100644 --- a/samples/client/petstore/powershell/src/PSPetstore/Client/PSConfiguration.ps1 +++ b/samples/client/petstore/powershell/src/PSPetstore/Client/PSConfiguration.ps1 @@ -179,8 +179,8 @@ function Set-PSConfiguration { } If ($null -ne $Proxy) { - If ($Proxy.GetType().FullName -ne "System.Net.SystemWebProxy" -and $Proxy.GetType().FullName -ne "System.Net.WebRequest+WebProxyWrapperOpaque") { - throw "Incorrect Proxy type '$($Proxy.GetType().FullName)'. Must be System.Net.SystemWebProxy or System.Net.WebRequest+WebProxyWrapperOpaque." + If ('System.Net.IWebProxy' -notin $Proxy.GetType().ImplementedInterfaces.FullName) { + throw "Incorrect Proxy type '$($Proxy.GetType().FullName)'. Must implement System.Net.IWebProxy interface." } $Script:Configuration['Proxy'] = $Proxy } else {