[PowerShell] Add PowerShell API client generator (WIP) (#5789)

* add powershell generator (wip)

* minor fix to api template

* rename model files

* Powershell generator fix (#11)

* Fix typo

pacakge -> package

* Add missing `petstore` subfolder to $ClientPath

* Resolve $ClientPath to absolute path

Start-Process needs WorkingDirectory to be absolute

* Fix spaces in variable name

${ somevar } is a vairable that literally has spaces in name. We need to
temporarily redifine mustache delimiters so we can generate var. names
without spaces.

* Fix typo

Remove stray `r`

* Fix *.ps1 import in module

Directory structure has changed + we should export functions using
manifest.

* Remove erroneous file

* various fixes and enhancements

* remove nullable for string

* change function name based on feedback by beatcracker

* set index to start at 0

* fix file type

* Powershell generator fix 1 (#12)

* Add closing curly brace

* Fix duplicated '['

* Get FunctionsToExport using AST

Discussion: swagger-api/swagger-codegen#5789

* add guid option to powershell generator

* add test files, remove docs

* fix array of items

* clean up powershell comment, update model/api test files
This commit is contained in:
wing328
2017-06-20 22:20:05 +08:00
committed by GitHub
parent c26b5a1e1b
commit e53b3a03aa
72 changed files with 4237 additions and 0 deletions

View File

@@ -0,0 +1,25 @@
function New-ApiResponse {
[CmdletBinding()]
Param (
[Parameter(Position = 0, ValueFromPipelineByPropertyName = $true)]
[System.Nullable[Int32]]
${code},
[Parameter(Position = 0, ValueFromPipelineByPropertyName = $true)]
[String]
${type},
[Parameter(Position = 0, ValueFromPipelineByPropertyName = $true)]
[String]
${message}
)
Process {
'Creating object: IO.Swagger.Model.ApiResponse' | Write-Verbose
$PSBoundParameters | Out-DebugParameter | Write-Debug
New-Object -TypeName IO.Swagger.Model.ApiResponse -ArgumentList @(
${code},
${type},
${message}
)
}
}

View File

@@ -0,0 +1,21 @@
function New-Category {
[CmdletBinding()]
Param (
[Parameter(Position = 0, ValueFromPipelineByPropertyName = $true)]
[System.Nullable[Int64]]
${id},
[Parameter(Position = 0, ValueFromPipelineByPropertyName = $true)]
[String]
${name}
)
Process {
'Creating object: IO.Swagger.Model.Category' | Write-Verbose
$PSBoundParameters | Out-DebugParameter | Write-Debug
New-Object -TypeName IO.Swagger.Model.Category -ArgumentList @(
${id},
${name}
)
}
}

View File

@@ -0,0 +1,37 @@
function New-Order {
[CmdletBinding()]
Param (
[Parameter(Position = 0, ValueFromPipelineByPropertyName = $true)]
[System.Nullable[Int64]]
${id},
[Parameter(Position = 0, ValueFromPipelineByPropertyName = $true)]
[System.Nullable[Int64]]
${petId},
[Parameter(Position = 0, ValueFromPipelineByPropertyName = $true)]
[System.Nullable[Int32]]
${quantity},
[Parameter(Position = 0, ValueFromPipelineByPropertyName = $true)]
[System.Nullable[System.DateTime]]
${shipDate},
[Parameter(Position = 0, ValueFromPipelineByPropertyName = $true)]
[String]
${status},
[Parameter(Position = 0, ValueFromPipelineByPropertyName = $true)]
[System.Nullable[Boolean]]
${complete}
)
Process {
'Creating object: IO.Swagger.Model.Order' | Write-Verbose
$PSBoundParameters | Out-DebugParameter | Write-Debug
New-Object -TypeName IO.Swagger.Model.Order -ArgumentList @(
${id},
${petId},
${quantity},
${shipDate},
${status},
${complete}
)
}
}

View File

@@ -0,0 +1,37 @@
function New-Pet {
[CmdletBinding()]
Param (
[Parameter(Position = 0, ValueFromPipelineByPropertyName = $true)]
[System.Nullable[Int64]]
${id},
[Parameter(Position = 0, ValueFromPipelineByPropertyName = $true)]
[System.Nullable[IO.Swagger.Model.Category]]
${category},
[Parameter(Position = 0, ValueFromPipelineByPropertyName = $true, Mandatory = $true)]
[String]
${name},
[Parameter(Position = 0, ValueFromPipelineByPropertyName = $true, Mandatory = $true)]
[[String]]
${photoUrls},
[Parameter(Position = 0, ValueFromPipelineByPropertyName = $true)]
[System.Nullable[IO.Swagger.Model.Tag]]
${tags},
[Parameter(Position = 0, ValueFromPipelineByPropertyName = $true)]
[String]
${status}
)
Process {
'Creating object: IO.Swagger.Model.Pet' | Write-Verbose
$PSBoundParameters | Out-DebugParameter | Write-Debug
New-Object -TypeName IO.Swagger.Model.Pet -ArgumentList @(
${id},
${category},
${name},
${photoUrls},
${tags},
${status}
)
}
}

View File

@@ -0,0 +1,21 @@
function New-Tag {
[CmdletBinding()]
Param (
[Parameter(Position = 0, ValueFromPipelineByPropertyName = $true)]
[System.Nullable[Int64]]
${id},
[Parameter(Position = 0, ValueFromPipelineByPropertyName = $true)]
[String]
${name}
)
Process {
'Creating object: IO.Swagger.Model.Tag' | Write-Verbose
$PSBoundParameters | Out-DebugParameter | Write-Debug
New-Object -TypeName IO.Swagger.Model.Tag -ArgumentList @(
${id},
${name}
)
}
}

View File

@@ -0,0 +1,45 @@
function New-User {
[CmdletBinding()]
Param (
[Parameter(Position = 0, ValueFromPipelineByPropertyName = $true)]
[System.Nullable[Int64]]
${id},
[Parameter(Position = 0, ValueFromPipelineByPropertyName = $true)]
[String]
${username},
[Parameter(Position = 0, ValueFromPipelineByPropertyName = $true)]
[String]
${firstName},
[Parameter(Position = 0, ValueFromPipelineByPropertyName = $true)]
[String]
${lastName},
[Parameter(Position = 0, ValueFromPipelineByPropertyName = $true)]
[String]
${email},
[Parameter(Position = 0, ValueFromPipelineByPropertyName = $true)]
[String]
${password},
[Parameter(Position = 0, ValueFromPipelineByPropertyName = $true)]
[String]
${phone},
[Parameter(Position = 0, ValueFromPipelineByPropertyName = $true)]
[System.Nullable[Int32]]
${userStatus}
)
Process {
'Creating object: IO.Swagger.Model.User' | Write-Verbose
$PSBoundParameters | Out-DebugParameter | Write-Debug
New-Object -TypeName IO.Swagger.Model.User -ArgumentList @(
${id},
${username},
${firstName},
${lastName},
${email},
${password},
${phone},
${userStatus}
)
}
}