diff --git a/modules/openapi-generator/src/main/resources/powershell/api.mustache b/modules/openapi-generator/src/main/resources/powershell/api.mustache index f5840636bf6..14a18de62e0 100644 --- a/modules/openapi-generator/src/main/resources/powershell/api.mustache +++ b/modules/openapi-generator/src/main/resources/powershell/api.mustache @@ -90,7 +90,7 @@ function {{{vendorExtensions.x-powershell-method-name}}} { if (!$) { throw "Error! The required parameter `` missing when calling ." } - $LocalVarUri = $LocalVarUri.replace('{}', $) + $LocalVarUri = $LocalVarUri.replace('{}', [System.Web.HTTPUtility]::UrlEncode($)) <={{ }}=> diff --git a/samples/client/petstore/powershell/src/PSPetstore/Api/PSPetApi.ps1 b/samples/client/petstore/powershell/src/PSPetstore/Api/PSPetApi.ps1 index 4024745d0ca..b6c13d19fb1 100644 --- a/samples/client/petstore/powershell/src/PSPetstore/Api/PSPetApi.ps1 +++ b/samples/client/petstore/powershell/src/PSPetstore/Api/PSPetApi.ps1 @@ -150,7 +150,7 @@ function Remove-Pet { if (!$PetId) { throw "Error! The required parameter `PetId` missing when calling deletePet." } - $LocalVarUri = $LocalVarUri.replace('{petId}', $PetId) + $LocalVarUri = $LocalVarUri.replace('{petId}', [System.Web.HTTPUtility]::UrlEncode($PetId)) if ($ApiKey) { $LocalVarHeaderParameters['api_key'] = $ApiKey @@ -415,7 +415,7 @@ function Get-PSPetById { if (!$PetId) { throw "Error! The required parameter `PetId` missing when calling getPetById." } - $LocalVarUri = $LocalVarUri.replace('{petId}', $PetId) + $LocalVarUri = $LocalVarUri.replace('{petId}', [System.Web.HTTPUtility]::UrlEncode($PetId)) if ($Configuration["ApiKey"] -and $Configuration["ApiKey"]["api_key"]) { $LocalVarHeaderParameters['api_key'] = $Configuration["ApiKey"]["api_key"] @@ -596,7 +596,7 @@ function Update-PSPetWithForm { if (!$PetId) { throw "Error! The required parameter `PetId` missing when calling updatePetWithForm." } - $LocalVarUri = $LocalVarUri.replace('{petId}', $PetId) + $LocalVarUri = $LocalVarUri.replace('{petId}', [System.Web.HTTPUtility]::UrlEncode($PetId)) if ($Name) { $LocalVarFormParameters['name'] = $Name @@ -693,7 +693,7 @@ function Invoke-PSUploadFile { if (!$PetId) { throw "Error! The required parameter `PetId` missing when calling uploadFile." } - $LocalVarUri = $LocalVarUri.replace('{petId}', $PetId) + $LocalVarUri = $LocalVarUri.replace('{petId}', [System.Web.HTTPUtility]::UrlEncode($PetId)) if ($AdditionalMetadata) { $LocalVarFormParameters['additionalMetadata'] = $AdditionalMetadata diff --git a/samples/client/petstore/powershell/src/PSPetstore/Api/PSStoreApi.ps1 b/samples/client/petstore/powershell/src/PSPetstore/Api/PSStoreApi.ps1 index ae56dcdd258..da64d177edd 100644 --- a/samples/client/petstore/powershell/src/PSPetstore/Api/PSStoreApi.ps1 +++ b/samples/client/petstore/powershell/src/PSPetstore/Api/PSStoreApi.ps1 @@ -53,7 +53,7 @@ function Remove-PSOrder { if (!$OrderId) { throw "Error! The required parameter `OrderId` missing when calling deleteOrder." } - $LocalVarUri = $LocalVarUri.replace('{orderId}', $OrderId) + $LocalVarUri = $LocalVarUri.replace('{orderId}', [System.Web.HTTPUtility]::UrlEncode($OrderId)) $LocalVarResult = Invoke-PSApiClient -Method 'DELETE' ` -Uri $LocalVarUri ` @@ -206,7 +206,7 @@ function Get-PSOrderById { if (!$OrderId) { throw "Error! The required parameter `OrderId` missing when calling getOrderById." } - $LocalVarUri = $LocalVarUri.replace('{orderId}', $OrderId) + $LocalVarUri = $LocalVarUri.replace('{orderId}', [System.Web.HTTPUtility]::UrlEncode($OrderId)) $LocalVarResult = Invoke-PSApiClient -Method 'GET' ` -Uri $LocalVarUri ` diff --git a/samples/client/petstore/powershell/src/PSPetstore/Api/PSUserApi.ps1 b/samples/client/petstore/powershell/src/PSPetstore/Api/PSUserApi.ps1 index cbf47aace79..b1bf3241a10 100644 --- a/samples/client/petstore/powershell/src/PSPetstore/Api/PSUserApi.ps1 +++ b/samples/client/petstore/powershell/src/PSPetstore/Api/PSUserApi.ps1 @@ -293,7 +293,7 @@ function Remove-PSUser { if (!$Username) { throw "Error! The required parameter `Username` missing when calling deleteUser." } - $LocalVarUri = $LocalVarUri.replace('{username}', $Username) + $LocalVarUri = $LocalVarUri.replace('{username}', [System.Web.HTTPUtility]::UrlEncode($Username)) if ($Configuration["Cookie"]) { $LocalVarCookieParameters['auth_cookie'] = $Configuration["Cookie"] @@ -383,7 +383,7 @@ function Get-PSUserByName { if (!$Username) { throw "Error! The required parameter `Username` missing when calling getUserByName." } - $LocalVarUri = $LocalVarUri.replace('{username}', $Username) + $LocalVarUri = $LocalVarUri.replace('{username}', [System.Web.HTTPUtility]::UrlEncode($Username)) $LocalVarResult = Invoke-PSApiClient -Method 'GET' ` -Uri $LocalVarUri ` @@ -624,7 +624,7 @@ function Update-PSUser { if (!$Username) { throw "Error! The required parameter `Username` missing when calling updateUser." } - $LocalVarUri = $LocalVarUri.replace('{username}', $Username) + $LocalVarUri = $LocalVarUri.replace('{username}', [System.Web.HTTPUtility]::UrlEncode($Username)) if (!$User) { throw "Error! The required parameter `User` missing when calling updateUser."