Skip to content

Commit

Permalink
[PowerShell] Fix map type (#5638)
Browse files Browse the repository at this point in the history
* fix map type

* remove output type, fix appveyor

* test macos

* comment out failing scala test

* fix typo: configuration

* Revert "comment out failing scala test"

This reverts commit 1dcf84f.
  • Loading branch information
wing328 authored Mar 23, 2020
1 parent 6ceb3ff commit 57eb1a0
Show file tree
Hide file tree
Showing 8 changed files with 34 additions and 53 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -548,9 +548,7 @@ public String getTypeDeclaration(Schema p) {
Schema inner = ap.getItems();
return getTypeDeclaration(inner) + "[]";
} else if (ModelUtils.isMapSchema(p)) {
Schema inner = ModelUtils.getAdditionalProperties(p);
// TODO not sure if the following map/hash declaration is correct
return "{String, " + getTypeDeclaration(inner) + "}";
return "Hashtable";
} else if (!languageSpecificPrimitives.contains(getSchemaType(p))) {
return super.getTypeDeclaration(p);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
{{#operations}}
{{#operation}}
function {{{vendorExtensions.x-powershell-method-name}}} {
    [OutputType({{#returnType}}"{{{.}}}"{{/returnType}}{{^returnType}}[System.Void]{{/returnType}})]
[CmdletBinding()]
Param (
{{#allParams}}
Expand All @@ -27,7 +26,7 @@ function {{{vendorExtensions.x-powershell-method-name}}} {
$LocalVarCookieParameters = @{}
$LocalVarBodyParameter

$Configuraiton = Get-{{{apiNamePrefix}}}Configuration
$Configuration = Get-{{{apiNamePrefix}}}Configuration
{{#hasProduces}}
# HTTP header 'Accept' (if needed)
$LocalVarAccepts = @({{#produces}}'{{{mediaType}}}'{{#hasMore}}, {{/hasMore}}{{/produces}})
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
{{> partial_header}}
version: 1.0.{build}
image:
- Visual Studio 2017
- Ubuntu
- Visual Studio 2017 # PS 5.x
- Ubuntu # PS 6.x
- macOS # PS 6.x
install:
- ps: $PSVersionTable.PSVersion
- ps: Install-Module Pester -Force -Scope CurrentUser
build: off
test_script:
Expand Down
6 changes: 4 additions & 2 deletions samples/client/petstore/powershell-experimental/appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,11 @@

version: 1.0.{build}
image:
- Visual Studio 2017
- Ubuntu
- Visual Studio 2017 # PS 5.x
- Ubuntu # PS 6.x
- macOS # PS 6.x
install:
- ps: $PSVersionTable.PSVersion
- ps: Install-Module Pester -Force -Scope CurrentUser
build: off
test_script:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ No authorization required

<a name="Get-PSInventory"></a>
# **Get-PSInventory**
> {String, Int32} Get-PSInventory<br>
> Hashtable Get-PSInventory<br>
Returns pet inventories by status

Expand All @@ -76,7 +76,7 @@ $Configuration["ApiKey"]["api_key"] = "YOUR_API_KEY"
# Returns pet inventories by status
try {
{String, Int32} $Result = Get-PSInventory
Hashtable $Result = Get-PSInventory
} catch {
Write-Host ($_.ErrorDetails | ConvertFrom-Json)
Write-Host ($_.Exception.Response.Headers | ConvertTo-Json)
Expand All @@ -88,7 +88,7 @@ This endpoint does not need any parameter.

### Return type

**{String, Int32}**
**Hashtable**

### Authorization

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
#

function Add-PSPet {
    [OutputType("Pet")]
[CmdletBinding()]
Param (
[Parameter(Position = 0, ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true, Mandatory = $false)]
Expand All @@ -27,7 +26,7 @@ function Add-PSPet {
$LocalVarCookieParameters = @{}
$LocalVarBodyParameter

$Configuraiton = Get-PSConfiguration
$Configuration = Get-PSConfiguration
# HTTP header 'Accept' (if needed)
$LocalVarAccepts = @('application/xml', 'application/json')

Expand Down Expand Up @@ -59,7 +58,6 @@ function Add-PSPet {
}

function Remove-Pet {
    [OutputType([System.Void])]
[CmdletBinding()]
Param (
[Parameter(Position = 0, ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true, Mandatory = $false)]
Expand All @@ -83,7 +81,7 @@ function Remove-Pet {
$LocalVarCookieParameters = @{}
$LocalVarBodyParameter

$Configuraiton = Get-PSConfiguration
$Configuration = Get-PSConfiguration
$LocalVarUri = '/pet/{petId}'
if (!$PetId) {
throw "Error! The required parameter `PetId` missing when calling deletePet."
Expand Down Expand Up @@ -111,7 +109,6 @@ function Remove-Pet {
}

function Find-PSPetsByStatus {
    [OutputType("Pet[]")]
[CmdletBinding()]
Param (
[Parameter(Position = 0, ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true, Mandatory = $false)]
Expand All @@ -132,7 +129,7 @@ function Find-PSPetsByStatus {
$LocalVarCookieParameters = @{}
$LocalVarBodyParameter

$Configuraiton = Get-PSConfiguration
$Configuration = Get-PSConfiguration
# HTTP header 'Accept' (if needed)
$LocalVarAccepts = @('application/xml', 'application/json')

Expand Down Expand Up @@ -160,7 +157,6 @@ function Find-PSPetsByStatus {
}

function Find-PSPetsByTags {
    [OutputType("Pet[]")]
[CmdletBinding()]
Param (
[Parameter(Position = 0, ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true, Mandatory = $false)]
Expand All @@ -181,7 +177,7 @@ function Find-PSPetsByTags {
$LocalVarCookieParameters = @{}
$LocalVarBodyParameter

$Configuraiton = Get-PSConfiguration
$Configuration = Get-PSConfiguration
# HTTP header 'Accept' (if needed)
$LocalVarAccepts = @('application/xml', 'application/json')

Expand Down Expand Up @@ -209,7 +205,6 @@ function Find-PSPetsByTags {
}

function Get-PSPetById {
    [OutputType("Pet")]
[CmdletBinding()]
Param (
[Parameter(Position = 0, ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true, Mandatory = $false)]
Expand All @@ -230,7 +225,7 @@ function Get-PSPetById {
$LocalVarCookieParameters = @{}
$LocalVarBodyParameter

$Configuraiton = Get-PSConfiguration
$Configuration = Get-PSConfiguration
# HTTP header 'Accept' (if needed)
$LocalVarAccepts = @('application/xml', 'application/json')

Expand Down Expand Up @@ -260,7 +255,6 @@ function Get-PSPetById {
}

function Update-PSPet {
    [OutputType("Pet")]
[CmdletBinding()]
Param (
[Parameter(Position = 0, ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true, Mandatory = $false)]
Expand All @@ -281,7 +275,7 @@ function Update-PSPet {
$LocalVarCookieParameters = @{}
$LocalVarBodyParameter

$Configuraiton = Get-PSConfiguration
$Configuration = Get-PSConfiguration
# HTTP header 'Accept' (if needed)
$LocalVarAccepts = @('application/xml', 'application/json')

Expand Down Expand Up @@ -313,7 +307,6 @@ function Update-PSPet {
}

function Update-PSPetWithForm {
    [OutputType([System.Void])]
[CmdletBinding()]
Param (
[Parameter(Position = 0, ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true, Mandatory = $false)]
Expand All @@ -340,7 +333,7 @@ function Update-PSPetWithForm {
$LocalVarCookieParameters = @{}
$LocalVarBodyParameter

$Configuraiton = Get-PSConfiguration
$Configuration = Get-PSConfiguration
# HTTP header 'Content-Type'
$LocalVarContentTypes = @('application/x-www-form-urlencoded')

Expand Down Expand Up @@ -375,7 +368,6 @@ function Update-PSPetWithForm {
}

function Invoke-PSUploadFile {
    [OutputType("ApiResponse")]
[CmdletBinding()]
Param (
[Parameter(Position = 0, ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true, Mandatory = $false)]
Expand All @@ -402,7 +394,7 @@ function Invoke-PSUploadFile {
$LocalVarCookieParameters = @{}
$LocalVarBodyParameter

$Configuraiton = Get-PSConfiguration
$Configuration = Get-PSConfiguration
# HTTP header 'Accept' (if needed)
$LocalVarAccepts = @('application/json')

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
#

function Invoke-PSDeleteOrder {
    [OutputType([System.Void])]
[CmdletBinding()]
Param (
[Parameter(Position = 0, ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true, Mandatory = $false)]
Expand All @@ -27,7 +26,7 @@ function Invoke-PSDeleteOrder {
$LocalVarCookieParameters = @{}
$LocalVarBodyParameter

$Configuraiton = Get-PSConfiguration
$Configuration = Get-PSConfiguration
$LocalVarUri = '/store/order/{orderId}'
if (!$OrderId) {
throw "Error! The required parameter `OrderId` missing when calling deleteOrder."
Expand All @@ -50,7 +49,6 @@ function Invoke-PSDeleteOrder {
}

function Get-PSInventory {
    [OutputType("{String, Int32}")]
[CmdletBinding()]
Param (
)
Expand All @@ -68,7 +66,7 @@ function Get-PSInventory {
$LocalVarCookieParameters = @{}
$LocalVarBodyParameter

$Configuraiton = Get-PSConfiguration
$Configuration = Get-PSConfiguration
# HTTP header 'Accept' (if needed)
$LocalVarAccepts = @('application/json')

Expand All @@ -87,14 +85,13 @@ function Get-PSInventory {
-QueryParameters $LocalVarQueryParameters `
-FormParameters $LocalVarFormParameters `
-CookieParameters $LocalVarCookieParameters `
-ReturnType "{String, Int32}"
-ReturnType "Hashtable"

return $LocalVarResult["Response"]
}
}

function Get-PSOrderById {
    [OutputType("Order")]
[CmdletBinding()]
Param (
[Parameter(Position = 0, ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true, Mandatory = $false)]
Expand All @@ -115,7 +112,7 @@ function Get-PSOrderById {
$LocalVarCookieParameters = @{}
$LocalVarBodyParameter

$Configuraiton = Get-PSConfiguration
$Configuration = Get-PSConfiguration
# HTTP header 'Accept' (if needed)
$LocalVarAccepts = @('application/xml', 'application/json')

Expand All @@ -141,7 +138,6 @@ function Get-PSOrderById {
}

function Invoke-PSPlaceOrder {
    [OutputType("Order")]
[CmdletBinding()]
Param (
[Parameter(Position = 0, ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true, Mandatory = $false)]
Expand All @@ -162,7 +158,7 @@ function Invoke-PSPlaceOrder {
$LocalVarCookieParameters = @{}
$LocalVarBodyParameter

$Configuraiton = Get-PSConfiguration
$Configuration = Get-PSConfiguration
# HTTP header 'Accept' (if needed)
$LocalVarAccepts = @('application/xml', 'application/json')

Expand Down
Loading

0 comments on commit 57eb1a0

Please sign in to comment.