diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/PowerShellExperimentalClientCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/PowerShellExperimentalClientCodegen.java index 3f6166177d8..e4aa8748c36 100644 --- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/PowerShellExperimentalClientCodegen.java +++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/PowerShellExperimentalClientCodegen.java @@ -253,9 +253,6 @@ public class PowerShellExperimentalClientCodegen extends DefaultCodegen implemen } } - // additional common verbs mapping - commonVerbs.put("Delete", "Remove"); - powershellVerbs = new HashSet(Arrays.asList( "Add", "Clear", @@ -1014,7 +1011,7 @@ public class PowerShellExperimentalClientCodegen extends DefaultCodegen implemen for (Map.Entry entry : commonVerbs.entrySet()) { if (methodName.startsWith(entry.getKey())) { methodName = entry.getValue() + "-" + apiNamePrefix + methodName.substring(entry.getKey().length()); - LOGGER.info("Naming the method using the common verb (e.g. Create, Delete, Update): {} => {}", operationId, methodName); + LOGGER.info("Naming the method by mapping the common verbs (e.g. Create, Change) to PS verbs: {} => {}", operationId, methodName); return methodName; } } 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 12a1d0c18fb..40c0801c097 100644 --- a/modules/openapi-generator/src/main/resources/powershell-experimental/api.mustache +++ b/modules/openapi-generator/src/main/resources/powershell-experimental/api.mustache @@ -151,16 +151,19 @@ function {{{vendorExtensions.x-powershell-method-name}}} { {{#isKeyInHeader}} if ($Configuration["ApiKey"] -and $Configuration["ApiKey"]["{{{name}}}"]) { $LocalVarHeaderParameters['{{{name}}}'] = $Configuration["ApiKey"]["{{{name}}}"] + Write-Verbose ("Using API key '{{{name}}}' in the header for authentication in {0}" -f $MyInvocation.MyCommand) } {{/isKeyInHeader}} {{#isKeyInQuery}} if ($Configuration["ApiKey"] -and $Configuration["ApiKey"]["{{{name}}}"]) { $LocalVarQueryParameters['{{{name}}}'] = $Configuration["ApiKey"]["{{{name}}}"] + Write-Verbose ("Using API key `{{{name}}}` in the URL query for authentication in {0}" -f $MyInvocation.MyCommand) } {{/isKeyInQuery}} {{#isKeyInCookie}} if ($Configuration["Cookie"]) { $LocalVarCookieParameters['{{{name}}}'] = $Configuration["Cookie"] + Write-Verbose ("Using API key `{{{name}}}` in the cookie for authentication in {0}" -f $MyInvocation.MyCommand) } {{/isKeyInCookie}} {{/isApiKey}} @@ -169,11 +172,13 @@ function {{{vendorExtensions.x-powershell-method-name}}} { $LocalVarBytes = [System.Text.Encoding]::UTF8.GetBytes($Configuration["Username"] + ":" + $Configuration["Password"]) $LocalVarBase64Text =[Convert]::ToBase64String($LocalVarBytes) $LocalVarHeaderParameters['Authorization'] = "Basic " + $LocalVarBase64Text + Write-Verbose ("Using HTTP basic authentication in {0}" -f $MyInvocation.MyCommand) } {{/isBasicBasic}} {{#isBasicBearer}} if ($Configuration["AccessToken"]) { $LocalVarHeaderParameters['Authorization'] = "Bearer " + $Configuration["AccessToken"] + Write-Verbose ("Using Bearer authentication in {0}" -f $MyInvocation.MyCommand) } {{/isBasicBearer}} diff --git a/modules/openapi-generator/src/main/resources/powershell-experimental/api_doc.mustache b/modules/openapi-generator/src/main/resources/powershell-experimental/api_doc.mustache index 4453fa9c3cb..97e5de1b693 100644 --- a/modules/openapi-generator/src/main/resources/powershell-experimental/api_doc.mustache +++ b/modules/openapi-generator/src/main/resources/powershell-experimental/api_doc.mustache @@ -56,8 +56,8 @@ ${{paramName}} = {{{vendorExtensions.x-powershell-example}}} # {{{dataType}}} | try { {{#returnType}}{{returnType}} $Result = {{/returnType}}{{{vendorExtensions.x-powershell-method-name}}}{{#allParams}} -{{paramName}} ${{paramName}}{{/allParams}} } catch { - Write-Host ($_.ErrorDetails | ConvertFrom-Json) - Write-Host ($_.Exception.Response.Headers | ConvertTo-Json) + Write-Host ("Exception occured when calling {{{vendorExtensions.x-powershell-method-name}}}: {0}" -f ($_.ErrorDetails | ConvertFrom-Json)) + Write-Host ("Response headers: {0}" -f ($_.Exception.Response.Headers | ConvertTo-Json)) } ``` diff --git a/samples/client/petstore/powershell-experimental/Test1.ps1 b/samples/client/petstore/powershell-experimental/Test1.ps1 index 67dbb552bde..b7e92caf90f 100644 --- a/samples/client/petstore/powershell-experimental/Test1.ps1 +++ b/samples/client/petstore/powershell-experimental/Test1.ps1 @@ -18,13 +18,13 @@ $Id = 38369 #$result = Update-PSPetWithForm try { Set-PSConfigurationApiKey -Id "api_key" -ApiKey "zzZZZZZZZZZZZZZ" - $result = Get-PSPetById -petId $Id #-testHeader "testing only" -testQuery "testing something here" + $result = Get-PSPetById -petId $Id -Verbose #-testHeader "testing only" -testQuery "testing something here" } catch { - Write-Host ($_.ErrorDetails | ConvertFrom-Json) - Write-Host ($_.Exception.Response.Headers | ConvertTo-Json) + Write-Host ("Exception occured when calling '': {0}" -f ($_.ErrorDetails | ConvertFrom-Json)) + Write-Host ("Response headers: {0}" -f ($_.Exception.Response.Headers | ConvertTo-Json)) } -$result | Write-Host +#$result | Write-Host #$result | Select-Object -Property "photoUrls" | ConvertTo-Json | Write-Host #Write-Host "result =" + $result.photoUrls diff --git a/samples/client/petstore/powershell-experimental/docs/PSPetApi.md b/samples/client/petstore/powershell-experimental/docs/PSPetApi.md index 7ff1d74a74f..78129e0be7b 100644 --- a/samples/client/petstore/powershell-experimental/docs/PSPetApi.md +++ b/samples/client/petstore/powershell-experimental/docs/PSPetApi.md @@ -35,8 +35,8 @@ $Pet = (Initialize-Pet-Id 123 -Category (Initialize-Category-Id 123 -Name "Name_ try { Pet $Result = Add-PSPet -Pet $Pet } catch { - Write-Host ($_.ErrorDetails | ConvertFrom-Json) - Write-Host ($_.Exception.Response.Headers | ConvertTo-Json) + Write-Host ("Exception occured when calling Add-PSPet: {0}" -f ($_.ErrorDetails | ConvertFrom-Json)) + Write-Host ("Response headers: {0}" -f ($_.Exception.Response.Headers | ConvertTo-Json)) } ``` @@ -84,8 +84,8 @@ $ApiKey = "ApiKey_example" # String | (optional) (default to null) try { Remove-Pet -PetId $PetId -ApiKey $ApiKey } catch { - Write-Host ($_.ErrorDetails | ConvertFrom-Json) - Write-Host ($_.Exception.Response.Headers | ConvertTo-Json) + Write-Host ("Exception occured when calling Remove-Pet: {0}" -f ($_.ErrorDetails | ConvertFrom-Json)) + Write-Host ("Response headers: {0}" -f ($_.Exception.Response.Headers | ConvertTo-Json)) } ``` @@ -134,8 +134,8 @@ $Status = @("Status_example") # String[] | Status values that need to be conside try { Pet[] $Result = Find-PSPetsByStatus -Status $Status } catch { - Write-Host ($_.ErrorDetails | ConvertFrom-Json) - Write-Host ($_.Exception.Response.Headers | ConvertTo-Json) + Write-Host ("Exception occured when calling Find-PSPetsByStatus: {0}" -f ($_.ErrorDetails | ConvertFrom-Json)) + Write-Host ("Response headers: {0}" -f ($_.Exception.Response.Headers | ConvertTo-Json)) } ``` @@ -183,8 +183,8 @@ $Tags = @("Inner_example") # String[] | Tags to filter by (default to null) try { Pet[] $Result = Find-PSPetsByTags -Tags $Tags } catch { - Write-Host ($_.ErrorDetails | ConvertFrom-Json) - Write-Host ($_.Exception.Response.Headers | ConvertTo-Json) + Write-Host ("Exception occured when calling Find-PSPetsByTags: {0}" -f ($_.ErrorDetails | ConvertFrom-Json)) + Write-Host ("Response headers: {0}" -f ($_.Exception.Response.Headers | ConvertTo-Json)) } ``` @@ -234,8 +234,8 @@ $PetId = 987 # Int64 | ID of pet to return (default to null) try { Pet $Result = Get-PSPetById -PetId $PetId } catch { - Write-Host ($_.ErrorDetails | ConvertFrom-Json) - Write-Host ($_.Exception.Response.Headers | ConvertTo-Json) + Write-Host ("Exception occured when calling Get-PSPetById: {0}" -f ($_.ErrorDetails | ConvertFrom-Json)) + Write-Host ("Response headers: {0}" -f ($_.Exception.Response.Headers | ConvertTo-Json)) } ``` @@ -281,8 +281,8 @@ $Pet = (Initialize-Pet-Id 123 -Category (Initialize-Category-Id 123 -Name "Name_ try { Pet $Result = Update-PSPet -Pet $Pet } catch { - Write-Host ($_.ErrorDetails | ConvertFrom-Json) - Write-Host ($_.Exception.Response.Headers | ConvertTo-Json) + Write-Host ("Exception occured when calling Update-PSPet: {0}" -f ($_.ErrorDetails | ConvertFrom-Json)) + Write-Host ("Response headers: {0}" -f ($_.Exception.Response.Headers | ConvertTo-Json)) } ``` @@ -332,8 +332,8 @@ $Status = "Status_example" # String | Updated status of the pet (optional) (defa try { Update-PSPetWithForm -PetId $PetId -Name $Name -Status $Status } catch { - Write-Host ($_.ErrorDetails | ConvertFrom-Json) - Write-Host ($_.Exception.Response.Headers | ConvertTo-Json) + Write-Host ("Exception occured when calling Update-PSPetWithForm: {0}" -f ($_.ErrorDetails | ConvertFrom-Json)) + Write-Host ("Response headers: {0}" -f ($_.Exception.Response.Headers | ConvertTo-Json)) } ``` @@ -385,8 +385,8 @@ $File = 987 # System.IO.FileInfo | file to upload (optional) (default to null) try { ApiResponse $Result = Invoke-PSUploadFile -PetId $PetId -AdditionalMetadata $AdditionalMetadata -File $File } catch { - Write-Host ($_.ErrorDetails | ConvertFrom-Json) - Write-Host ($_.Exception.Response.Headers | ConvertTo-Json) + Write-Host ("Exception occured when calling Invoke-PSUploadFile: {0}" -f ($_.ErrorDetails | ConvertFrom-Json)) + Write-Host ("Response headers: {0}" -f ($_.Exception.Response.Headers | ConvertTo-Json)) } ``` diff --git a/samples/client/petstore/powershell-experimental/docs/PSStoreApi.md b/samples/client/petstore/powershell-experimental/docs/PSStoreApi.md index 9979c451667..bfb991c5129 100644 --- a/samples/client/petstore/powershell-experimental/docs/PSStoreApi.md +++ b/samples/client/petstore/powershell-experimental/docs/PSStoreApi.md @@ -29,8 +29,8 @@ $OrderId = "OrderId_example" # String | ID of the order that needs to be deleted try { Remove-PSOrder -OrderId $OrderId } catch { - Write-Host ($_.ErrorDetails | ConvertFrom-Json) - Write-Host ($_.Exception.Response.Headers | ConvertTo-Json) + Write-Host ("Exception occured when calling Remove-PSOrder: {0}" -f ($_.ErrorDetails | ConvertFrom-Json)) + Write-Host ("Response headers: {0}" -f ($_.Exception.Response.Headers | ConvertTo-Json)) } ``` @@ -78,8 +78,8 @@ $Configuration["ApiKey"]["api_key"] = "YOUR_API_KEY" try { System.Collections.Hashtable $Result = Get-PSInventory } catch { - Write-Host ($_.ErrorDetails | ConvertFrom-Json) - Write-Host ($_.Exception.Response.Headers | ConvertTo-Json) + Write-Host ("Exception occured when calling Get-PSInventory: {0}" -f ($_.ErrorDetails | ConvertFrom-Json)) + Write-Host ("Response headers: {0}" -f ($_.Exception.Response.Headers | ConvertTo-Json)) } ``` @@ -120,8 +120,8 @@ $OrderId = 987 # Int64 | ID of pet that needs to be fetched (default to null) try { Order $Result = Get-PSOrderById -OrderId $OrderId } catch { - Write-Host ($_.ErrorDetails | ConvertFrom-Json) - Write-Host ($_.Exception.Response.Headers | ConvertTo-Json) + Write-Host ("Exception occured when calling Get-PSOrderById: {0}" -f ($_.ErrorDetails | ConvertFrom-Json)) + Write-Host ("Response headers: {0}" -f ($_.Exception.Response.Headers | ConvertTo-Json)) } ``` @@ -163,8 +163,8 @@ $Order = (Initialize-Order-Id 123 -PetId 123 -Quantity 123 -ShipDate Get-Date -S try { Order $Result = Invoke-PSPlaceOrder -Order $Order } catch { - Write-Host ($_.ErrorDetails | ConvertFrom-Json) - Write-Host ($_.Exception.Response.Headers | ConvertTo-Json) + Write-Host ("Exception occured when calling Invoke-PSPlaceOrder: {0}" -f ($_.ErrorDetails | ConvertFrom-Json)) + Write-Host ("Response headers: {0}" -f ($_.Exception.Response.Headers | ConvertTo-Json)) } ``` diff --git a/samples/client/petstore/powershell-experimental/docs/PSUserApi.md b/samples/client/petstore/powershell-experimental/docs/PSUserApi.md index f8eb41bc03b..1b5de280e7d 100644 --- a/samples/client/petstore/powershell-experimental/docs/PSUserApi.md +++ b/samples/client/petstore/powershell-experimental/docs/PSUserApi.md @@ -39,8 +39,8 @@ $User = (Initialize-User-Id 123 -Username "Username_example" -FirstName "FirstNa try { New-PSUser -User $User } catch { - Write-Host ($_.ErrorDetails | ConvertFrom-Json) - Write-Host ($_.Exception.Response.Headers | ConvertTo-Json) + Write-Host ("Exception occured when calling New-PSUser: {0}" -f ($_.ErrorDetails | ConvertFrom-Json)) + Write-Host ("Response headers: {0}" -f ($_.Exception.Response.Headers | ConvertTo-Json)) } ``` @@ -88,8 +88,8 @@ $User = @((Initialize-User-Id 123 -Username "Username_example" -FirstName "First try { New-PSUsersWithArrayInput -User $User } catch { - Write-Host ($_.ErrorDetails | ConvertFrom-Json) - Write-Host ($_.Exception.Response.Headers | ConvertTo-Json) + Write-Host ("Exception occured when calling New-PSUsersWithArrayInput: {0}" -f ($_.ErrorDetails | ConvertFrom-Json)) + Write-Host ("Response headers: {0}" -f ($_.Exception.Response.Headers | ConvertTo-Json)) } ``` @@ -137,8 +137,8 @@ $User = @() # User[] | List of user object try { New-PSUsersWithListInput -User $User } catch { - Write-Host ($_.ErrorDetails | ConvertFrom-Json) - Write-Host ($_.Exception.Response.Headers | ConvertTo-Json) + Write-Host ("Exception occured when calling New-PSUsersWithListInput: {0}" -f ($_.ErrorDetails | ConvertFrom-Json)) + Write-Host ("Response headers: {0}" -f ($_.Exception.Response.Headers | ConvertTo-Json)) } ``` @@ -188,8 +188,8 @@ $Username = "Username_example" # String | The name that needs to be deleted (def try { Remove-PSUser -Username $Username } catch { - Write-Host ($_.ErrorDetails | ConvertFrom-Json) - Write-Host ($_.Exception.Response.Headers | ConvertTo-Json) + Write-Host ("Exception occured when calling Remove-PSUser: {0}" -f ($_.ErrorDetails | ConvertFrom-Json)) + Write-Host ("Response headers: {0}" -f ($_.Exception.Response.Headers | ConvertTo-Json)) } ``` @@ -231,8 +231,8 @@ $Username = "Username_example" # String | The name that needs to be fetched. Use try { User $Result = Get-PSUserByName -Username $Username } catch { - Write-Host ($_.ErrorDetails | ConvertFrom-Json) - Write-Host ($_.Exception.Response.Headers | ConvertTo-Json) + Write-Host ("Exception occured when calling Get-PSUserByName: {0}" -f ($_.ErrorDetails | ConvertFrom-Json)) + Write-Host ("Response headers: {0}" -f ($_.Exception.Response.Headers | ConvertTo-Json)) } ``` @@ -276,8 +276,8 @@ $Password = "Password_example" # String | The password for login in clear text ( try { String $Result = Invoke-PSLoginUser -Username $Username -Password $Password } catch { - Write-Host ($_.ErrorDetails | ConvertFrom-Json) - Write-Host ($_.Exception.Response.Headers | ConvertTo-Json) + Write-Host ("Exception occured when calling Invoke-PSLoginUser: {0}" -f ($_.ErrorDetails | ConvertFrom-Json)) + Write-Host ("Response headers: {0}" -f ($_.Exception.Response.Headers | ConvertTo-Json)) } ``` @@ -324,8 +324,8 @@ $Configuration["ApiKey"]["AUTH_KEY"] = "YOUR_API_KEY" try { Invoke-PSLogoutUser } catch { - Write-Host ($_.ErrorDetails | ConvertFrom-Json) - Write-Host ($_.Exception.Response.Headers | ConvertTo-Json) + Write-Host ("Exception occured when calling Invoke-PSLogoutUser: {0}" -f ($_.ErrorDetails | ConvertFrom-Json)) + Write-Host ("Response headers: {0}" -f ($_.Exception.Response.Headers | ConvertTo-Json)) } ``` @@ -374,8 +374,8 @@ $User = # User | Updated user object try { Update-PSUser -Username $Username -User $User } catch { - Write-Host ($_.ErrorDetails | ConvertFrom-Json) - Write-Host ($_.Exception.Response.Headers | ConvertTo-Json) + Write-Host ("Exception occured when calling Update-PSUser: {0}" -f ($_.ErrorDetails | ConvertFrom-Json)) + Write-Host ("Response headers: {0}" -f ($_.Exception.Response.Headers | ConvertTo-Json)) } ``` 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 3df26a59eef..e12f2d6681f 100644 --- a/samples/client/petstore/powershell-experimental/src/PSPetstore/API/PSPetApi.ps1 +++ b/samples/client/petstore/powershell-experimental/src/PSPetstore/API/PSPetApi.ps1 @@ -320,6 +320,7 @@ function Get-PSPetById { if ($Configuration["ApiKey"] -and $Configuration["ApiKey"]["api_key"]) { $LocalVarHeaderParameters['api_key'] = $Configuration["ApiKey"]["api_key"] + Write-Verbose ("Using API key 'api_key' in the header for authentication in {0}" -f $MyInvocation.MyCommand) } $LocalVarResult = Invoke-PSApiClient -Method 'GET' ` 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 931b9c40ff0..9979ff2962a 100644 --- a/samples/client/petstore/powershell-experimental/src/PSPetstore/API/PSStoreApi.ps1 +++ b/samples/client/petstore/powershell-experimental/src/PSPetstore/API/PSStoreApi.ps1 @@ -103,6 +103,7 @@ function Get-PSInventory { if ($Configuration["ApiKey"] -and $Configuration["ApiKey"]["api_key"]) { $LocalVarHeaderParameters['api_key'] = $Configuration["ApiKey"]["api_key"] + Write-Verbose ("Using API key 'api_key' in the header for authentication in {0}" -f $MyInvocation.MyCommand) } $LocalVarResult = Invoke-PSApiClient -Method 'GET' ` 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 08073729399..46da75ffc8b 100644 --- a/samples/client/petstore/powershell-experimental/src/PSPetstore/API/PSUserApi.ps1 +++ b/samples/client/petstore/powershell-experimental/src/PSPetstore/API/PSUserApi.ps1 @@ -56,6 +56,7 @@ function New-PSUser { if ($Configuration["Cookie"]) { $LocalVarCookieParameters['auth_cookie'] = $Configuration["Cookie"] + Write-Verbose ("Using API key `auth_cookie` in the cookie for authentication in {0}" -f $MyInvocation.MyCommand) } $LocalVarResult = Invoke-PSApiClient -Method 'POST' ` @@ -124,6 +125,7 @@ function New-PSUsersWithArrayInput { if ($Configuration["Cookie"]) { $LocalVarCookieParameters['auth_cookie'] = $Configuration["Cookie"] + Write-Verbose ("Using API key `auth_cookie` in the cookie for authentication in {0}" -f $MyInvocation.MyCommand) } $LocalVarResult = Invoke-PSApiClient -Method 'POST' ` @@ -192,6 +194,7 @@ function New-PSUsersWithListInput { if ($Configuration["Cookie"]) { $LocalVarCookieParameters['auth_cookie'] = $Configuration["Cookie"] + Write-Verbose ("Using API key `auth_cookie` in the cookie for authentication in {0}" -f $MyInvocation.MyCommand) } $LocalVarResult = Invoke-PSApiClient -Method 'POST' ` @@ -255,6 +258,7 @@ function Remove-PSUser { if ($Configuration["Cookie"]) { $LocalVarCookieParameters['auth_cookie'] = $Configuration["Cookie"] + Write-Verbose ("Using API key `auth_cookie` in the cookie for authentication in {0}" -f $MyInvocation.MyCommand) } $LocalVarResult = Invoke-PSApiClient -Method 'DELETE' ` @@ -444,6 +448,7 @@ function Invoke-PSLogoutUser { if ($Configuration["Cookie"]) { $LocalVarCookieParameters['auth_cookie'] = $Configuration["Cookie"] + Write-Verbose ("Using API key `auth_cookie` in the cookie for authentication in {0}" -f $MyInvocation.MyCommand) } $LocalVarResult = Invoke-PSApiClient -Method 'GET' ` @@ -522,6 +527,7 @@ function Update-PSUser { if ($Configuration["Cookie"]) { $LocalVarCookieParameters['auth_cookie'] = $Configuration["Cookie"] + Write-Verbose ("Using API key `auth_cookie` in the cookie for authentication in {0}" -f $MyInvocation.MyCommand) } $LocalVarResult = Invoke-PSApiClient -Method 'PUT' ` diff --git a/samples/client/petstore/powershell-experimental/src/PSPetstore/PSPetstore.psd1 b/samples/client/petstore/powershell-experimental/src/PSPetstore/PSPetstore.psd1 index 687388e9e19..7093b2a8783 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/1/20 +# Generated on: 4/2/20 # @{