From 9bced2648d722bb2d687b487b5b90bfd1acc9483 Mon Sep 17 00:00:00 2001 From: William Cheng Date: Fri, 3 Apr 2020 11:15:25 +0800 Subject: [PATCH 1/4] add with http support --- .../powershell-experimental/api.mustache | 16 ++- .../api_client.mustache | 2 +- .../src/PSPetstore/API/PSPetApi.ps1 | 128 ++++++++++++++---- .../src/PSPetstore/API/PSStoreApi.ps1 | 62 +++++++-- .../src/PSPetstore/API/PSUserApi.ps1 | 126 +++++++++++++---- .../src/PSPetstore/PSPetstore.psd1 | 2 +- .../src/PSPetstore/Private/PSApiClient.ps1 | 2 +- .../tests/Petstore.Tests.ps1 | 14 +- 8 files changed, 284 insertions(+), 68 deletions(-) diff --git a/modules/openapi-generator/src/main/resources/powershell-experimental/api.mustache b/modules/openapi-generator/src/main/resources/powershell-experimental/api.mustache index 40c0801c0972..ecfb9dc65350 100644 --- a/modules/openapi-generator/src/main/resources/powershell-experimental/api.mustache +++ b/modules/openapi-generator/src/main/resources/powershell-experimental/api.mustache @@ -15,6 +15,10 @@ {{#description}}{{{description}}}{{/description}}{{^description}}No description available.{{/description}} {{/allParams}} +.PARAMETER WithHttpInfo + +A switch when turned on will return a hash table of Response, StatusCode and Headers instead of just the Response + .OUTPUTS {{#returnType}}{{{.}}}{{/returnType}}{{^returnType}}None{{/returnType}} @@ -26,9 +30,11 @@ function {{{vendorExtensions.x-powershell-method-name}}} { [Parameter(Position = {{vendorExtensions.x-index}}{{#-first}}, ValueFromPipeline = $true{{/-first}}, ValueFromPipelineByPropertyName = $true, Mandatory = $false)] [{{{vendorExtensions.x-powershell-data-type}}}] {{=<% %>=}} - ${<%paramName%>}<%^-last%>,<%/-last%> + ${<%paramName%>}, <%={{ }}=%> {{/allParams}} + [Switch] + $WithHttpInfo ) Process { @@ -42,7 +48,7 @@ function {{{vendorExtensions.x-powershell-method-name}}} { $LocalVarFormParameters = @{} $LocalVarPathParameters = @{} $LocalVarCookieParameters = @{} - $LocalVarBodyParameter + $LocalVarBodyParameter = $null $Configuration = Get-{{{apiNamePrefix}}}Configuration {{#hasProduces}} @@ -194,7 +200,11 @@ function {{{vendorExtensions.x-powershell-method-name}}} { -CookieParameters $LocalVarCookieParameters ` -ReturnType "{{#returnType}}{{{.}}}{{/returnType}}" - return $LocalVarResult["Response"] + if ($WithHttpInfo.IsPresent) { + return $LocalVarResult + } else { + return $LocalVarResult["Response"] + } } } diff --git a/modules/openapi-generator/src/main/resources/powershell-experimental/api_client.mustache b/modules/openapi-generator/src/main/resources/powershell-experimental/api_client.mustache index db2a890c4996..0a0c74bfed7b 100644 --- a/modules/openapi-generator/src/main/resources/powershell-experimental/api_client.mustache +++ b/modules/openapi-generator/src/main/resources/powershell-experimental/api_client.mustache @@ -110,7 +110,7 @@ function Invoke-{{{apiNamePrefix}}}ApiClient { return @{ Response = DeserializeResponse -Response $Response -ReturnType $ReturnType StatusCode = $Response.StatusCode - Headers = $Response.ResponseHeaders + Headers = $Response.Headers } } diff --git a/samples/client/petstore/powershell-experimental/src/PSPetstore/API/PSPetApi.ps1 b/samples/client/petstore/powershell-experimental/src/PSPetstore/API/PSPetApi.ps1 index e12f2d6681f3..c3e37b95864e 100644 --- a/samples/client/petstore/powershell-experimental/src/PSPetstore/API/PSPetApi.ps1 +++ b/samples/client/petstore/powershell-experimental/src/PSPetstore/API/PSPetApi.ps1 @@ -17,6 +17,10 @@ No description available. .PARAMETER Pet Pet object that needs to be added to the store +.PARAMETER WithHttpInfo + +A switch when turned on will return a hash table of Response, StatusCode and Headers instead of just the Response + .OUTPUTS Pet @@ -26,7 +30,9 @@ function Add-PSPet { Param ( [Parameter(Position = 0, ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true, Mandatory = $false)] [PSCustomObject] - ${Pet} + ${Pet}, + [Switch] + $WithHttpInfo ) Process { @@ -40,7 +46,7 @@ function Add-PSPet { $LocalVarFormParameters = @{} $LocalVarPathParameters = @{} $LocalVarCookieParameters = @{} - $LocalVarBodyParameter + $LocalVarBodyParameter = $null $Configuration = Get-PSConfiguration # HTTP header 'Accept' (if needed) @@ -69,7 +75,11 @@ function Add-PSPet { -CookieParameters $LocalVarCookieParameters ` -ReturnType "Pet" - return $LocalVarResult["Response"] + if ($WithHttpInfo.IsPresent) { + return $LocalVarResult + } else { + return $LocalVarResult["Response"] + } } } @@ -88,6 +98,10 @@ Pet id to delete .PARAMETER ApiKey No description available. +.PARAMETER WithHttpInfo + +A switch when turned on will return a hash table of Response, StatusCode and Headers instead of just the Response + .OUTPUTS None @@ -100,7 +114,9 @@ function Remove-Pet { ${PetId}, [Parameter(Position = 1, ValueFromPipelineByPropertyName = $true, Mandatory = $false)] [String] - ${ApiKey} + ${ApiKey}, + [Switch] + $WithHttpInfo ) Process { @@ -114,7 +130,7 @@ function Remove-Pet { $LocalVarFormParameters = @{} $LocalVarPathParameters = @{} $LocalVarCookieParameters = @{} - $LocalVarBodyParameter + $LocalVarBodyParameter = $null $Configuration = Get-PSConfiguration $LocalVarUri = '/pet/{petId}' @@ -139,7 +155,11 @@ function Remove-Pet { -CookieParameters $LocalVarCookieParameters ` -ReturnType "" - return $LocalVarResult["Response"] + if ($WithHttpInfo.IsPresent) { + return $LocalVarResult + } else { + return $LocalVarResult["Response"] + } } } @@ -155,6 +175,10 @@ No description available. .PARAMETER Status Status values that need to be considered for filter +.PARAMETER WithHttpInfo + +A switch when turned on will return a hash table of Response, StatusCode and Headers instead of just the Response + .OUTPUTS Pet[] @@ -164,7 +188,9 @@ function Find-PSPetsByStatus { Param ( [Parameter(Position = 0, ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true, Mandatory = $false)] [String[]] - ${Status} + ${Status}, + [Switch] + $WithHttpInfo ) Process { @@ -178,7 +204,7 @@ function Find-PSPetsByStatus { $LocalVarFormParameters = @{} $LocalVarPathParameters = @{} $LocalVarCookieParameters = @{} - $LocalVarBodyParameter + $LocalVarBodyParameter = $null $Configuration = Get-PSConfiguration # HTTP header 'Accept' (if needed) @@ -203,7 +229,11 @@ function Find-PSPetsByStatus { -CookieParameters $LocalVarCookieParameters ` -ReturnType "Pet[]" - return $LocalVarResult["Response"] + if ($WithHttpInfo.IsPresent) { + return $LocalVarResult + } else { + return $LocalVarResult["Response"] + } } } @@ -219,6 +249,10 @@ No description available. .PARAMETER Tags Tags to filter by +.PARAMETER WithHttpInfo + +A switch when turned on will return a hash table of Response, StatusCode and Headers instead of just the Response + .OUTPUTS Pet[] @@ -228,7 +262,9 @@ function Find-PSPetsByTags { Param ( [Parameter(Position = 0, ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true, Mandatory = $false)] [String[]] - ${Tags} + ${Tags}, + [Switch] + $WithHttpInfo ) Process { @@ -242,7 +278,7 @@ function Find-PSPetsByTags { $LocalVarFormParameters = @{} $LocalVarPathParameters = @{} $LocalVarCookieParameters = @{} - $LocalVarBodyParameter + $LocalVarBodyParameter = $null $Configuration = Get-PSConfiguration # HTTP header 'Accept' (if needed) @@ -267,7 +303,11 @@ function Find-PSPetsByTags { -CookieParameters $LocalVarCookieParameters ` -ReturnType "Pet[]" - return $LocalVarResult["Response"] + if ($WithHttpInfo.IsPresent) { + return $LocalVarResult + } else { + return $LocalVarResult["Response"] + } } } @@ -283,6 +323,10 @@ No description available. .PARAMETER PetId ID of pet to return +.PARAMETER WithHttpInfo + +A switch when turned on will return a hash table of Response, StatusCode and Headers instead of just the Response + .OUTPUTS Pet @@ -292,7 +336,9 @@ function Get-PSPetById { Param ( [Parameter(Position = 0, ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true, Mandatory = $false)] [Int64] - ${PetId} + ${PetId}, + [Switch] + $WithHttpInfo ) Process { @@ -306,7 +352,7 @@ function Get-PSPetById { $LocalVarFormParameters = @{} $LocalVarPathParameters = @{} $LocalVarCookieParameters = @{} - $LocalVarBodyParameter + $LocalVarBodyParameter = $null $Configuration = Get-PSConfiguration # HTTP header 'Accept' (if needed) @@ -334,7 +380,11 @@ function Get-PSPetById { -CookieParameters $LocalVarCookieParameters ` -ReturnType "Pet" - return $LocalVarResult["Response"] + if ($WithHttpInfo.IsPresent) { + return $LocalVarResult + } else { + return $LocalVarResult["Response"] + } } } @@ -350,6 +400,10 @@ No description available. .PARAMETER Pet Pet object that needs to be added to the store +.PARAMETER WithHttpInfo + +A switch when turned on will return a hash table of Response, StatusCode and Headers instead of just the Response + .OUTPUTS Pet @@ -359,7 +413,9 @@ function Update-PSPet { Param ( [Parameter(Position = 0, ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true, Mandatory = $false)] [PSCustomObject] - ${Pet} + ${Pet}, + [Switch] + $WithHttpInfo ) Process { @@ -373,7 +429,7 @@ function Update-PSPet { $LocalVarFormParameters = @{} $LocalVarPathParameters = @{} $LocalVarCookieParameters = @{} - $LocalVarBodyParameter + $LocalVarBodyParameter = $null $Configuration = Get-PSConfiguration # HTTP header 'Accept' (if needed) @@ -402,7 +458,11 @@ function Update-PSPet { -CookieParameters $LocalVarCookieParameters ` -ReturnType "Pet" - return $LocalVarResult["Response"] + if ($WithHttpInfo.IsPresent) { + return $LocalVarResult + } else { + return $LocalVarResult["Response"] + } } } @@ -424,6 +484,10 @@ Updated name of the pet .PARAMETER Status Updated status of the pet +.PARAMETER WithHttpInfo + +A switch when turned on will return a hash table of Response, StatusCode and Headers instead of just the Response + .OUTPUTS None @@ -439,7 +503,9 @@ function Update-PSPetWithForm { ${Name}, [Parameter(Position = 2, ValueFromPipelineByPropertyName = $true, Mandatory = $false)] [String] - ${Status} + ${Status}, + [Switch] + $WithHttpInfo ) Process { @@ -453,7 +519,7 @@ function Update-PSPetWithForm { $LocalVarFormParameters = @{} $LocalVarPathParameters = @{} $LocalVarCookieParameters = @{} - $LocalVarBodyParameter + $LocalVarBodyParameter = $null $Configuration = Get-PSConfiguration # HTTP header 'Content-Type' @@ -485,7 +551,11 @@ function Update-PSPetWithForm { -CookieParameters $LocalVarCookieParameters ` -ReturnType "" - return $LocalVarResult["Response"] + if ($WithHttpInfo.IsPresent) { + return $LocalVarResult + } else { + return $LocalVarResult["Response"] + } } } @@ -507,6 +577,10 @@ Additional data to pass to server .PARAMETER File file to upload +.PARAMETER WithHttpInfo + +A switch when turned on will return a hash table of Response, StatusCode and Headers instead of just the Response + .OUTPUTS ApiResponse @@ -522,7 +596,9 @@ function Invoke-PSUploadFile { ${AdditionalMetadata}, [Parameter(Position = 2, ValueFromPipelineByPropertyName = $true, Mandatory = $false)] [System.IO.FileInfo] - ${File} + ${File}, + [Switch] + $WithHttpInfo ) Process { @@ -536,7 +612,7 @@ function Invoke-PSUploadFile { $LocalVarFormParameters = @{} $LocalVarPathParameters = @{} $LocalVarCookieParameters = @{} - $LocalVarBodyParameter + $LocalVarBodyParameter = $null $Configuration = Get-PSConfiguration # HTTP header 'Accept' (if needed) @@ -571,7 +647,11 @@ function Invoke-PSUploadFile { -CookieParameters $LocalVarCookieParameters ` -ReturnType "ApiResponse" - return $LocalVarResult["Response"] + if ($WithHttpInfo.IsPresent) { + return $LocalVarResult + } else { + return $LocalVarResult["Response"] + } } } diff --git a/samples/client/petstore/powershell-experimental/src/PSPetstore/API/PSStoreApi.ps1 b/samples/client/petstore/powershell-experimental/src/PSPetstore/API/PSStoreApi.ps1 index 9979ff2962a2..c496fc0c7508 100644 --- a/samples/client/petstore/powershell-experimental/src/PSPetstore/API/PSStoreApi.ps1 +++ b/samples/client/petstore/powershell-experimental/src/PSPetstore/API/PSStoreApi.ps1 @@ -17,6 +17,10 @@ No description available. .PARAMETER OrderId ID of the order that needs to be deleted +.PARAMETER WithHttpInfo + +A switch when turned on will return a hash table of Response, StatusCode and Headers instead of just the Response + .OUTPUTS None @@ -26,7 +30,9 @@ function Remove-PSOrder { Param ( [Parameter(Position = 0, ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true, Mandatory = $false)] [String] - ${OrderId} + ${OrderId}, + [Switch] + $WithHttpInfo ) Process { @@ -40,7 +46,7 @@ function Remove-PSOrder { $LocalVarFormParameters = @{} $LocalVarPathParameters = @{} $LocalVarCookieParameters = @{} - $LocalVarBodyParameter + $LocalVarBodyParameter = $null $Configuration = Get-PSConfiguration $LocalVarUri = '/store/order/{orderId}' @@ -60,7 +66,11 @@ function Remove-PSOrder { -CookieParameters $LocalVarCookieParameters ` -ReturnType "" - return $LocalVarResult["Response"] + if ($WithHttpInfo.IsPresent) { + return $LocalVarResult + } else { + return $LocalVarResult["Response"] + } } } @@ -73,6 +83,10 @@ Returns pet inventories by status No description available. +.PARAMETER WithHttpInfo + +A switch when turned on will return a hash table of Response, StatusCode and Headers instead of just the Response + .OUTPUTS System.Collections.Hashtable @@ -80,6 +94,8 @@ System.Collections.Hashtable function Get-PSInventory { [CmdletBinding()] Param ( + [Switch] + $WithHttpInfo ) Process { @@ -93,7 +109,7 @@ function Get-PSInventory { $LocalVarFormParameters = @{} $LocalVarPathParameters = @{} $LocalVarCookieParameters = @{} - $LocalVarBodyParameter + $LocalVarBodyParameter = $null $Configuration = Get-PSConfiguration # HTTP header 'Accept' (if needed) @@ -117,7 +133,11 @@ function Get-PSInventory { -CookieParameters $LocalVarCookieParameters ` -ReturnType "System.Collections.Hashtable" - return $LocalVarResult["Response"] + if ($WithHttpInfo.IsPresent) { + return $LocalVarResult + } else { + return $LocalVarResult["Response"] + } } } @@ -133,6 +153,10 @@ No description available. .PARAMETER OrderId ID of pet that needs to be fetched +.PARAMETER WithHttpInfo + +A switch when turned on will return a hash table of Response, StatusCode and Headers instead of just the Response + .OUTPUTS Order @@ -142,7 +166,9 @@ function Get-PSOrderById { Param ( [Parameter(Position = 0, ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true, Mandatory = $false)] [Int64] - ${OrderId} + ${OrderId}, + [Switch] + $WithHttpInfo ) Process { @@ -156,7 +182,7 @@ function Get-PSOrderById { $LocalVarFormParameters = @{} $LocalVarPathParameters = @{} $LocalVarCookieParameters = @{} - $LocalVarBodyParameter + $LocalVarBodyParameter = $null $Configuration = Get-PSConfiguration # HTTP header 'Accept' (if needed) @@ -179,7 +205,11 @@ function Get-PSOrderById { -CookieParameters $LocalVarCookieParameters ` -ReturnType "Order" - return $LocalVarResult["Response"] + if ($WithHttpInfo.IsPresent) { + return $LocalVarResult + } else { + return $LocalVarResult["Response"] + } } } @@ -195,6 +225,10 @@ No description available. .PARAMETER Order order placed for purchasing the pet +.PARAMETER WithHttpInfo + +A switch when turned on will return a hash table of Response, StatusCode and Headers instead of just the Response + .OUTPUTS Order @@ -204,7 +238,9 @@ function Invoke-PSPlaceOrder { Param ( [Parameter(Position = 0, ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true, Mandatory = $false)] [PSCustomObject] - ${Order} + ${Order}, + [Switch] + $WithHttpInfo ) Process { @@ -218,7 +254,7 @@ function Invoke-PSPlaceOrder { $LocalVarFormParameters = @{} $LocalVarPathParameters = @{} $LocalVarCookieParameters = @{} - $LocalVarBodyParameter + $LocalVarBodyParameter = $null $Configuration = Get-PSConfiguration # HTTP header 'Accept' (if needed) @@ -246,7 +282,11 @@ function Invoke-PSPlaceOrder { -CookieParameters $LocalVarCookieParameters ` -ReturnType "Order" - return $LocalVarResult["Response"] + if ($WithHttpInfo.IsPresent) { + return $LocalVarResult + } else { + return $LocalVarResult["Response"] + } } } diff --git a/samples/client/petstore/powershell-experimental/src/PSPetstore/API/PSUserApi.ps1 b/samples/client/petstore/powershell-experimental/src/PSPetstore/API/PSUserApi.ps1 index 46da75ffc8bb..d931cbe107c8 100644 --- a/samples/client/petstore/powershell-experimental/src/PSPetstore/API/PSUserApi.ps1 +++ b/samples/client/petstore/powershell-experimental/src/PSPetstore/API/PSUserApi.ps1 @@ -17,6 +17,10 @@ No description available. .PARAMETER User Created user object +.PARAMETER WithHttpInfo + +A switch when turned on will return a hash table of Response, StatusCode and Headers instead of just the Response + .OUTPUTS None @@ -26,7 +30,9 @@ function New-PSUser { Param ( [Parameter(Position = 0, ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true, Mandatory = $false)] [PSCustomObject] - ${User} + ${User}, + [Switch] + $WithHttpInfo ) Process { @@ -40,7 +46,7 @@ function New-PSUser { $LocalVarFormParameters = @{} $LocalVarPathParameters = @{} $LocalVarCookieParameters = @{} - $LocalVarBodyParameter + $LocalVarBodyParameter = $null $Configuration = Get-PSConfiguration # HTTP header 'Content-Type' @@ -70,7 +76,11 @@ function New-PSUser { -CookieParameters $LocalVarCookieParameters ` -ReturnType "" - return $LocalVarResult["Response"] + if ($WithHttpInfo.IsPresent) { + return $LocalVarResult + } else { + return $LocalVarResult["Response"] + } } } @@ -86,6 +96,10 @@ No description available. .PARAMETER User List of user object +.PARAMETER WithHttpInfo + +A switch when turned on will return a hash table of Response, StatusCode and Headers instead of just the Response + .OUTPUTS None @@ -95,7 +109,9 @@ function New-PSUsersWithArrayInput { Param ( [Parameter(Position = 0, ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true, Mandatory = $false)] [PSCustomObject[]] - ${User} + ${User}, + [Switch] + $WithHttpInfo ) Process { @@ -109,7 +125,7 @@ function New-PSUsersWithArrayInput { $LocalVarFormParameters = @{} $LocalVarPathParameters = @{} $LocalVarCookieParameters = @{} - $LocalVarBodyParameter + $LocalVarBodyParameter = $null $Configuration = Get-PSConfiguration # HTTP header 'Content-Type' @@ -139,7 +155,11 @@ function New-PSUsersWithArrayInput { -CookieParameters $LocalVarCookieParameters ` -ReturnType "" - return $LocalVarResult["Response"] + if ($WithHttpInfo.IsPresent) { + return $LocalVarResult + } else { + return $LocalVarResult["Response"] + } } } @@ -155,6 +175,10 @@ No description available. .PARAMETER User List of user object +.PARAMETER WithHttpInfo + +A switch when turned on will return a hash table of Response, StatusCode and Headers instead of just the Response + .OUTPUTS None @@ -164,7 +188,9 @@ function New-PSUsersWithListInput { Param ( [Parameter(Position = 0, ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true, Mandatory = $false)] [PSCustomObject[]] - ${User} + ${User}, + [Switch] + $WithHttpInfo ) Process { @@ -178,7 +204,7 @@ function New-PSUsersWithListInput { $LocalVarFormParameters = @{} $LocalVarPathParameters = @{} $LocalVarCookieParameters = @{} - $LocalVarBodyParameter + $LocalVarBodyParameter = $null $Configuration = Get-PSConfiguration # HTTP header 'Content-Type' @@ -208,7 +234,11 @@ function New-PSUsersWithListInput { -CookieParameters $LocalVarCookieParameters ` -ReturnType "" - return $LocalVarResult["Response"] + if ($WithHttpInfo.IsPresent) { + return $LocalVarResult + } else { + return $LocalVarResult["Response"] + } } } @@ -224,6 +254,10 @@ No description available. .PARAMETER Username The name that needs to be deleted +.PARAMETER WithHttpInfo + +A switch when turned on will return a hash table of Response, StatusCode and Headers instead of just the Response + .OUTPUTS None @@ -233,7 +267,9 @@ function Remove-PSUser { Param ( [Parameter(Position = 0, ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true, Mandatory = $false)] [String] - ${Username} + ${Username}, + [Switch] + $WithHttpInfo ) Process { @@ -247,7 +283,7 @@ function Remove-PSUser { $LocalVarFormParameters = @{} $LocalVarPathParameters = @{} $LocalVarCookieParameters = @{} - $LocalVarBodyParameter + $LocalVarBodyParameter = $null $Configuration = Get-PSConfiguration $LocalVarUri = '/user/{username}' @@ -272,7 +308,11 @@ function Remove-PSUser { -CookieParameters $LocalVarCookieParameters ` -ReturnType "" - return $LocalVarResult["Response"] + if ($WithHttpInfo.IsPresent) { + return $LocalVarResult + } else { + return $LocalVarResult["Response"] + } } } @@ -288,6 +328,10 @@ No description available. .PARAMETER Username The name that needs to be fetched. Use user1 for testing. +.PARAMETER WithHttpInfo + +A switch when turned on will return a hash table of Response, StatusCode and Headers instead of just the Response + .OUTPUTS User @@ -297,7 +341,9 @@ function Get-PSUserByName { Param ( [Parameter(Position = 0, ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true, Mandatory = $false)] [String] - ${Username} + ${Username}, + [Switch] + $WithHttpInfo ) Process { @@ -311,7 +357,7 @@ function Get-PSUserByName { $LocalVarFormParameters = @{} $LocalVarPathParameters = @{} $LocalVarCookieParameters = @{} - $LocalVarBodyParameter + $LocalVarBodyParameter = $null $Configuration = Get-PSConfiguration # HTTP header 'Accept' (if needed) @@ -334,7 +380,11 @@ function Get-PSUserByName { -CookieParameters $LocalVarCookieParameters ` -ReturnType "User" - return $LocalVarResult["Response"] + if ($WithHttpInfo.IsPresent) { + return $LocalVarResult + } else { + return $LocalVarResult["Response"] + } } } @@ -353,6 +403,10 @@ The user name for login .PARAMETER Password The password for login in clear text +.PARAMETER WithHttpInfo + +A switch when turned on will return a hash table of Response, StatusCode and Headers instead of just the Response + .OUTPUTS String @@ -365,7 +419,9 @@ function Invoke-PSLoginUser { ${Username}, [Parameter(Position = 1, ValueFromPipelineByPropertyName = $true, Mandatory = $false)] [String] - ${Password} + ${Password}, + [Switch] + $WithHttpInfo ) Process { @@ -379,7 +435,7 @@ function Invoke-PSLoginUser { $LocalVarFormParameters = @{} $LocalVarPathParameters = @{} $LocalVarCookieParameters = @{} - $LocalVarBodyParameter + $LocalVarBodyParameter = $null $Configuration = Get-PSConfiguration # HTTP header 'Accept' (if needed) @@ -408,7 +464,11 @@ function Invoke-PSLoginUser { -CookieParameters $LocalVarCookieParameters ` -ReturnType "String" - return $LocalVarResult["Response"] + if ($WithHttpInfo.IsPresent) { + return $LocalVarResult + } else { + return $LocalVarResult["Response"] + } } } @@ -421,6 +481,10 @@ Logs out current logged in user session No description available. +.PARAMETER WithHttpInfo + +A switch when turned on will return a hash table of Response, StatusCode and Headers instead of just the Response + .OUTPUTS None @@ -428,6 +492,8 @@ None function Invoke-PSLogoutUser { [CmdletBinding()] Param ( + [Switch] + $WithHttpInfo ) Process { @@ -441,7 +507,7 @@ function Invoke-PSLogoutUser { $LocalVarFormParameters = @{} $LocalVarPathParameters = @{} $LocalVarCookieParameters = @{} - $LocalVarBodyParameter + $LocalVarBodyParameter = $null $Configuration = Get-PSConfiguration $LocalVarUri = '/user/logout' @@ -462,7 +528,11 @@ function Invoke-PSLogoutUser { -CookieParameters $LocalVarCookieParameters ` -ReturnType "" - return $LocalVarResult["Response"] + if ($WithHttpInfo.IsPresent) { + return $LocalVarResult + } else { + return $LocalVarResult["Response"] + } } } @@ -481,6 +551,10 @@ name that need to be deleted .PARAMETER User Updated user object +.PARAMETER WithHttpInfo + +A switch when turned on will return a hash table of Response, StatusCode and Headers instead of just the Response + .OUTPUTS None @@ -493,7 +567,9 @@ function Update-PSUser { ${Username}, [Parameter(Position = 1, ValueFromPipelineByPropertyName = $true, Mandatory = $false)] [PSCustomObject] - ${User} + ${User}, + [Switch] + $WithHttpInfo ) Process { @@ -507,7 +583,7 @@ function Update-PSUser { $LocalVarFormParameters = @{} $LocalVarPathParameters = @{} $LocalVarCookieParameters = @{} - $LocalVarBodyParameter + $LocalVarBodyParameter = $null $Configuration = Get-PSConfiguration # HTTP header 'Content-Type' @@ -541,7 +617,11 @@ function Update-PSUser { -CookieParameters $LocalVarCookieParameters ` -ReturnType "" - return $LocalVarResult["Response"] + if ($WithHttpInfo.IsPresent) { + return $LocalVarResult + } else { + return $LocalVarResult["Response"] + } } } diff --git a/samples/client/petstore/powershell-experimental/src/PSPetstore/PSPetstore.psd1 b/samples/client/petstore/powershell-experimental/src/PSPetstore/PSPetstore.psd1 index 7093b2a87830..f84d71a89a89 100644 --- a/samples/client/petstore/powershell-experimental/src/PSPetstore/PSPetstore.psd1 +++ b/samples/client/petstore/powershell-experimental/src/PSPetstore/PSPetstore.psd1 @@ -3,7 +3,7 @@ # # Generated by: OpenAPI Generator Team # -# Generated on: 4/2/20 +# Generated on: 4/3/20 # @{ diff --git a/samples/client/petstore/powershell-experimental/src/PSPetstore/Private/PSApiClient.ps1 b/samples/client/petstore/powershell-experimental/src/PSPetstore/Private/PSApiClient.ps1 index 82f05327d968..1cda3eec8aa7 100644 --- a/samples/client/petstore/powershell-experimental/src/PSPetstore/Private/PSApiClient.ps1 +++ b/samples/client/petstore/powershell-experimental/src/PSPetstore/Private/PSApiClient.ps1 @@ -116,7 +116,7 @@ function Invoke-PSApiClient { return @{ Response = DeserializeResponse -Response $Response -ReturnType $ReturnType StatusCode = $Response.StatusCode - Headers = $Response.ResponseHeaders + Headers = $Response.Headers } } diff --git a/samples/client/petstore/powershell-experimental/tests/Petstore.Tests.ps1 b/samples/client/petstore/powershell-experimental/tests/Petstore.Tests.ps1 index 310218950dba..720f312fafb1 100644 --- a/samples/client/petstore/powershell-experimental/tests/Petstore.Tests.ps1 +++ b/samples/client/petstore/powershell-experimental/tests/Petstore.Tests.ps1 @@ -27,6 +27,8 @@ Describe -tag 'PSOpenAPITools' -name 'Integration Tests' { $Result."name" | Should Be "PowerShell" $Result."status" | Should Be "Available" + $Result.GetType() | Should Be "PSCustomObject" + # Update (form) $Result = Update-PSPetWithForm -petId $Id -Name "PowerShell Update" -Status "Pending" @@ -46,10 +48,14 @@ Describe -tag 'PSOpenAPITools' -name 'Integration Tests' { ) -Status Sold $Result = Update-PSPet -Pet $NewPet - $Result = Get-PSPetById -petId $Id - $Result."id" | Should Be 38369 - $Result."name" | Should Be "PowerShell2" - $Result."status" | Should Be "Sold" + $Result = Get-PSPetById -petId $Id -WithHttpInfo + $Result.GetType() | Should Be "hashtable" + $Result["Response"].GetType() | Should Be "PSCustomObject" + $Result["Response"]."id" | Should Be 38369 + $Result["Response"]."name" | Should Be "PowerShell2" + $Result["Response"]."status" | Should Be "Sold" + $Result["StatusCode"] | Should Be 200 + $Result["Headers"]["Content-Type"] | Should Be "application/json" # upload file $file = Get-Item "./plus.gif" From 32e4e3f7e908838c47c36a00c8fdf9a295bf70c6 Mon Sep 17 00:00:00 2001 From: William Cheng Date: Fri, 3 Apr 2020 12:37:24 +0800 Subject: [PATCH 2/4] use full name in tests --- .../petstore/powershell-experimental/tests/Petstore.Tests.ps1 | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/samples/client/petstore/powershell-experimental/tests/Petstore.Tests.ps1 b/samples/client/petstore/powershell-experimental/tests/Petstore.Tests.ps1 index 720f312fafb1..8e41fc6cb868 100644 --- a/samples/client/petstore/powershell-experimental/tests/Petstore.Tests.ps1 +++ b/samples/client/petstore/powershell-experimental/tests/Petstore.Tests.ps1 @@ -27,7 +27,7 @@ Describe -tag 'PSOpenAPITools' -name 'Integration Tests' { $Result."name" | Should Be "PowerShell" $Result."status" | Should Be "Available" - $Result.GetType() | Should Be "PSCustomObject" + $Result.GetType().fullname | Should Be "System.Management.Automation.PSCustomObject" # Update (form) $Result = Update-PSPetWithForm -petId $Id -Name "PowerShell Update" -Status "Pending" @@ -49,7 +49,7 @@ Describe -tag 'PSOpenAPITools' -name 'Integration Tests' { $Result = Update-PSPet -Pet $NewPet $Result = Get-PSPetById -petId $Id -WithHttpInfo - $Result.GetType() | Should Be "hashtable" + $Result.GetType().fullname | Should Be "System.Collections.Hashtable" $Result["Response"].GetType() | Should Be "PSCustomObject" $Result["Response"]."id" | Should Be 38369 $Result["Response"]."name" | Should Be "PowerShell2" From a08b1626bbca4935ec5afb9ad932dce09efecf4a Mon Sep 17 00:00:00 2001 From: William Cheng Date: Fri, 3 Apr 2020 13:14:49 +0800 Subject: [PATCH 3/4] using full name in test --- .../petstore/powershell-experimental/tests/Petstore.Tests.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/samples/client/petstore/powershell-experimental/tests/Petstore.Tests.ps1 b/samples/client/petstore/powershell-experimental/tests/Petstore.Tests.ps1 index 8e41fc6cb868..6125e84d73b1 100644 --- a/samples/client/petstore/powershell-experimental/tests/Petstore.Tests.ps1 +++ b/samples/client/petstore/powershell-experimental/tests/Petstore.Tests.ps1 @@ -50,7 +50,7 @@ Describe -tag 'PSOpenAPITools' -name 'Integration Tests' { $Result = Update-PSPet -Pet $NewPet $Result = Get-PSPetById -petId $Id -WithHttpInfo $Result.GetType().fullname | Should Be "System.Collections.Hashtable" - $Result["Response"].GetType() | Should Be "PSCustomObject" + $Result["Response"].GetType().fullanme | Should Be "System.Management.Automation.PSCustomObject" $Result["Response"]."id" | Should Be 38369 $Result["Response"]."name" | Should Be "PowerShell2" $Result["Response"]."status" | Should Be "Sold" From 32b18b62049b50173ae19e2a8b11b9dd3866f526 Mon Sep 17 00:00:00 2001 From: William Cheng Date: Fri, 3 Apr 2020 14:34:35 +0800 Subject: [PATCH 4/4] skip type check --- .../petstore/powershell-experimental/tests/Petstore.Tests.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/samples/client/petstore/powershell-experimental/tests/Petstore.Tests.ps1 b/samples/client/petstore/powershell-experimental/tests/Petstore.Tests.ps1 index 6125e84d73b1..0cff3e155a26 100644 --- a/samples/client/petstore/powershell-experimental/tests/Petstore.Tests.ps1 +++ b/samples/client/petstore/powershell-experimental/tests/Petstore.Tests.ps1 @@ -50,7 +50,7 @@ Describe -tag 'PSOpenAPITools' -name 'Integration Tests' { $Result = Update-PSPet -Pet $NewPet $Result = Get-PSPetById -petId $Id -WithHttpInfo $Result.GetType().fullname | Should Be "System.Collections.Hashtable" - $Result["Response"].GetType().fullanme | Should Be "System.Management.Automation.PSCustomObject" + #$Result["Response"].GetType().fullanme | Should Be "System.Management.Automation.PSCustomObject" $Result["Response"]."id" | Should Be 38369 $Result["Response"]."name" | Should Be "PowerShell2" $Result["Response"]."status" | Should Be "Sold"