Replace powershell generator with powershell-experimental generator (#6213)

* replace powershell generator with powershell-experimental generator

* add back samples

* add back scripts

* remove outdated script

* update doc
This commit is contained in:
William Cheng
2020-05-08 20:13:01 +08:00
committed by GitHub
parent 6e619e0a15
commit f327f01c19
118 changed files with 1423 additions and 2408 deletions

View File

@@ -0,0 +1,718 @@
#
# OpenAPI Petstore
# This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
# Version: 1.0.0
# Generated by OpenAPI Generator: https://openapi-generator.tech
#
<#
.SYNOPSIS
Add a new pet to the store
.DESCRIPTION
No description available.
.PARAMETER Pet
Pet object that needs to be added to the store
.PARAMETER ReturnType
Select the return type (optional): application/xml, application/json
.PARAMETER WithHttpInfo
A switch when turned on will return a hash table of Response, StatusCode and Headers instead of just the Response
.OUTPUTS
Pet
#>
function Add-PSPet {
[CmdletBinding()]
Param (
[Parameter(Position = 0, ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true, Mandatory = $false)]
[PSCustomObject]
${Pet},
[String]
[ValidateSet("application/xml", "application/json")]
$ReturnType,
[Switch]
$WithHttpInfo
)
Process {
'Calling method: Add-PSPet' | Write-Debug
$PSBoundParameters | Out-DebugParameter | Write-Debug
$LocalVarAccepts = @()
$LocalVarContentTypes = @()
$LocalVarQueryParameters = @{}
$LocalVarHeaderParameters = @{}
$LocalVarFormParameters = @{}
$LocalVarPathParameters = @{}
$LocalVarCookieParameters = @{}
$LocalVarBodyParameter = $null
$Configuration = Get-PSConfiguration
# HTTP header 'Accept' (if needed)
$LocalVarAccepts = @('application/xml', 'application/json')
if ($ReturnType) {
# use the return type (MIME) provided by the user
$LocalVarAccepts = @($ReturnType)
}
# HTTP header 'Content-Type'
$LocalVarContentTypes = @('application/json', 'application/xml')
$LocalVarUri = '/pet'
if (!$Pet) {
throw "Error! The required parameter `Pet` missing when calling addPet."
}
$LocalVarBodyParameter = $Pet | ConvertTo-Json
$LocalVarResult = Invoke-PSApiClient -Method 'POST' `
-Uri $LocalVarUri `
-Accepts $LocalVarAccepts `
-ContentTypes $LocalVarContentTypes `
-Body $LocalVarBodyParameter `
-HeaderParameters $LocalVarHeaderParameters `
-QueryParameters $LocalVarQueryParameters `
-FormParameters $LocalVarFormParameters `
-CookieParameters $LocalVarCookieParameters `
-ReturnType "Pet"
if ($WithHttpInfo.IsPresent) {
return $LocalVarResult
} else {
return $LocalVarResult["Response"]
}
}
}
<#
.SYNOPSIS
Deletes a pet
.DESCRIPTION
No description available.
.PARAMETER PetId
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
#>
function Remove-Pet {
[CmdletBinding()]
Param (
[Parameter(Position = 0, ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true, Mandatory = $false)]
[Int64]
${PetId},
[Parameter(Position = 1, ValueFromPipelineByPropertyName = $true, Mandatory = $false)]
[String]
${ApiKey},
[Switch]
$WithHttpInfo
)
Process {
'Calling method: Remove-Pet' | Write-Debug
$PSBoundParameters | Out-DebugParameter | Write-Debug
$LocalVarAccepts = @()
$LocalVarContentTypes = @()
$LocalVarQueryParameters = @{}
$LocalVarHeaderParameters = @{}
$LocalVarFormParameters = @{}
$LocalVarPathParameters = @{}
$LocalVarCookieParameters = @{}
$LocalVarBodyParameter = $null
$Configuration = Get-PSConfiguration
$LocalVarUri = '/pet/{petId}'
if (!$PetId) {
throw "Error! The required parameter `PetId` missing when calling deletePet."
}
$LocalVarUri = $LocalVarUri.replace('{petId}', $PetId)
if ($ApiKey) {
$LocalVarHeaderParameters['api_key'] = $ApiKey
}
$LocalVarResult = Invoke-PSApiClient -Method 'DELETE' `
-Uri $LocalVarUri `
-Accepts $LocalVarAccepts `
-ContentTypes $LocalVarContentTypes `
-Body $LocalVarBodyParameter `
-HeaderParameters $LocalVarHeaderParameters `
-QueryParameters $LocalVarQueryParameters `
-FormParameters $LocalVarFormParameters `
-CookieParameters $LocalVarCookieParameters `
-ReturnType ""
if ($WithHttpInfo.IsPresent) {
return $LocalVarResult
} else {
return $LocalVarResult["Response"]
}
}
}
<#
.SYNOPSIS
Finds Pets by status
.DESCRIPTION
No description available.
.PARAMETER Status
Status values that need to be considered for filter
.PARAMETER ReturnType
Select the return type (optional): application/xml, application/json
.PARAMETER WithHttpInfo
A switch when turned on will return a hash table of Response, StatusCode and Headers instead of just the Response
.OUTPUTS
Pet[]
#>
function Find-PSPetsByStatus {
[CmdletBinding()]
Param (
[Parameter(Position = 0, ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true, Mandatory = $false)]
[ValidateSet("available", "pending", "sold")]
[String[]]
${Status},
[String]
[ValidateSet("application/xml", "application/json")]
$ReturnType,
[Switch]
$WithHttpInfo
)
Process {
'Calling method: Find-PSPetsByStatus' | Write-Debug
$PSBoundParameters | Out-DebugParameter | Write-Debug
$LocalVarAccepts = @()
$LocalVarContentTypes = @()
$LocalVarQueryParameters = @{}
$LocalVarHeaderParameters = @{}
$LocalVarFormParameters = @{}
$LocalVarPathParameters = @{}
$LocalVarCookieParameters = @{}
$LocalVarBodyParameter = $null
$Configuration = Get-PSConfiguration
# HTTP header 'Accept' (if needed)
$LocalVarAccepts = @('application/xml', 'application/json')
if ($ReturnType) {
# use the return type (MIME) provided by the user
$LocalVarAccepts = @($ReturnType)
}
$LocalVarUri = '/pet/findByStatus'
if (!$Status) {
throw "Error! The required parameter `Status` missing when calling findPetsByStatus."
}
$LocalVarQueryParameters['status'] = $Status
$LocalVarResult = Invoke-PSApiClient -Method 'GET' `
-Uri $LocalVarUri `
-Accepts $LocalVarAccepts `
-ContentTypes $LocalVarContentTypes `
-Body $LocalVarBodyParameter `
-HeaderParameters $LocalVarHeaderParameters `
-QueryParameters $LocalVarQueryParameters `
-FormParameters $LocalVarFormParameters `
-CookieParameters $LocalVarCookieParameters `
-ReturnType "Pet[]"
if ($WithHttpInfo.IsPresent) {
return $LocalVarResult
} else {
return $LocalVarResult["Response"]
}
}
}
<#
.SYNOPSIS
Finds Pets by tags
.DESCRIPTION
No description available.
.PARAMETER Tags
Tags to filter by
.PARAMETER ReturnType
Select the return type (optional): application/xml, application/json
.PARAMETER WithHttpInfo
A switch when turned on will return a hash table of Response, StatusCode and Headers instead of just the Response
.OUTPUTS
Pet[]
#>
function Find-PSPetsByTags {
[CmdletBinding()]
Param (
[Parameter(Position = 0, ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true, Mandatory = $false)]
[String[]]
${Tags},
[String]
[ValidateSet("application/xml", "application/json")]
$ReturnType,
[Switch]
$WithHttpInfo
)
Process {
'Calling method: Find-PSPetsByTags' | Write-Debug
$PSBoundParameters | Out-DebugParameter | Write-Debug
$LocalVarAccepts = @()
$LocalVarContentTypes = @()
$LocalVarQueryParameters = @{}
$LocalVarHeaderParameters = @{}
$LocalVarFormParameters = @{}
$LocalVarPathParameters = @{}
$LocalVarCookieParameters = @{}
$LocalVarBodyParameter = $null
$Configuration = Get-PSConfiguration
# HTTP header 'Accept' (if needed)
$LocalVarAccepts = @('application/xml', 'application/json')
if ($ReturnType) {
# use the return type (MIME) provided by the user
$LocalVarAccepts = @($ReturnType)
}
$LocalVarUri = '/pet/findByTags'
if (!$Tags) {
throw "Error! The required parameter `Tags` missing when calling findPetsByTags."
}
$LocalVarQueryParameters['tags'] = $Tags
$LocalVarResult = Invoke-PSApiClient -Method 'GET' `
-Uri $LocalVarUri `
-Accepts $LocalVarAccepts `
-ContentTypes $LocalVarContentTypes `
-Body $LocalVarBodyParameter `
-HeaderParameters $LocalVarHeaderParameters `
-QueryParameters $LocalVarQueryParameters `
-FormParameters $LocalVarFormParameters `
-CookieParameters $LocalVarCookieParameters `
-ReturnType "Pet[]"
if ($WithHttpInfo.IsPresent) {
return $LocalVarResult
} else {
return $LocalVarResult["Response"]
}
}
}
<#
.SYNOPSIS
Find pet by ID
.DESCRIPTION
No description available.
.PARAMETER PetId
ID of pet to return
.PARAMETER ReturnType
Select the return type (optional): application/xml, application/json
.PARAMETER WithHttpInfo
A switch when turned on will return a hash table of Response, StatusCode and Headers instead of just the Response
.OUTPUTS
Pet
#>
function Get-PSPetById {
[CmdletBinding()]
Param (
[Parameter(Position = 0, ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true, Mandatory = $false)]
[Int64]
${PetId},
[String]
[ValidateSet("application/xml", "application/json")]
$ReturnType,
[Switch]
$WithHttpInfo
)
Process {
'Calling method: Get-PSPetById' | Write-Debug
$PSBoundParameters | Out-DebugParameter | Write-Debug
$LocalVarAccepts = @()
$LocalVarContentTypes = @()
$LocalVarQueryParameters = @{}
$LocalVarHeaderParameters = @{}
$LocalVarFormParameters = @{}
$LocalVarPathParameters = @{}
$LocalVarCookieParameters = @{}
$LocalVarBodyParameter = $null
$Configuration = Get-PSConfiguration
# HTTP header 'Accept' (if needed)
$LocalVarAccepts = @('application/xml', 'application/json')
if ($ReturnType) {
# use the return type (MIME) provided by the user
$LocalVarAccepts = @($ReturnType)
}
$LocalVarUri = '/pet/{petId}'
if (!$PetId) {
throw "Error! The required parameter `PetId` missing when calling getPetById."
}
$LocalVarUri = $LocalVarUri.replace('{petId}', $PetId)
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' `
-Uri $LocalVarUri `
-Accepts $LocalVarAccepts `
-ContentTypes $LocalVarContentTypes `
-Body $LocalVarBodyParameter `
-HeaderParameters $LocalVarHeaderParameters `
-QueryParameters $LocalVarQueryParameters `
-FormParameters $LocalVarFormParameters `
-CookieParameters $LocalVarCookieParameters `
-ReturnType "Pet"
if ($WithHttpInfo.IsPresent) {
return $LocalVarResult
} else {
return $LocalVarResult["Response"]
}
}
}
<#
.SYNOPSIS
Update an existing pet
.DESCRIPTION
No description available.
.PARAMETER Pet
Pet object that needs to be added to the store
.PARAMETER ReturnType
Select the return type (optional): application/xml, application/json
.PARAMETER WithHttpInfo
A switch when turned on will return a hash table of Response, StatusCode and Headers instead of just the Response
.OUTPUTS
Pet
#>
function Update-PSPet {
[CmdletBinding()]
Param (
[Parameter(Position = 0, ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true, Mandatory = $false)]
[PSCustomObject]
${Pet},
[String]
[ValidateSet("application/xml", "application/json")]
$ReturnType,
[Switch]
$WithHttpInfo
)
Process {
'Calling method: Update-PSPet' | Write-Debug
$PSBoundParameters | Out-DebugParameter | Write-Debug
$LocalVarAccepts = @()
$LocalVarContentTypes = @()
$LocalVarQueryParameters = @{}
$LocalVarHeaderParameters = @{}
$LocalVarFormParameters = @{}
$LocalVarPathParameters = @{}
$LocalVarCookieParameters = @{}
$LocalVarBodyParameter = $null
$Configuration = Get-PSConfiguration
# HTTP header 'Accept' (if needed)
$LocalVarAccepts = @('application/xml', 'application/json')
if ($ReturnType) {
# use the return type (MIME) provided by the user
$LocalVarAccepts = @($ReturnType)
}
# HTTP header 'Content-Type'
$LocalVarContentTypes = @('application/json', 'application/xml')
$LocalVarUri = '/pet'
if (!$Pet) {
throw "Error! The required parameter `Pet` missing when calling updatePet."
}
$LocalVarBodyParameter = $Pet | ConvertTo-Json
$LocalVarResult = Invoke-PSApiClient -Method 'PUT' `
-Uri $LocalVarUri `
-Accepts $LocalVarAccepts `
-ContentTypes $LocalVarContentTypes `
-Body $LocalVarBodyParameter `
-HeaderParameters $LocalVarHeaderParameters `
-QueryParameters $LocalVarQueryParameters `
-FormParameters $LocalVarFormParameters `
-CookieParameters $LocalVarCookieParameters `
-ReturnType "Pet"
if ($WithHttpInfo.IsPresent) {
return $LocalVarResult
} else {
return $LocalVarResult["Response"]
}
}
}
<#
.SYNOPSIS
Updates a pet in the store with form data
.DESCRIPTION
No description available.
.PARAMETER PetId
ID of pet that needs to be updated
.PARAMETER Name
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
#>
function Update-PSPetWithForm {
[CmdletBinding()]
Param (
[Parameter(Position = 0, ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true, Mandatory = $false)]
[Int64]
${PetId},
[Parameter(Position = 1, ValueFromPipelineByPropertyName = $true, Mandatory = $false)]
[String]
${Name},
[Parameter(Position = 2, ValueFromPipelineByPropertyName = $true, Mandatory = $false)]
[String]
${Status},
[Switch]
$WithHttpInfo
)
Process {
'Calling method: Update-PSPetWithForm' | Write-Debug
$PSBoundParameters | Out-DebugParameter | Write-Debug
$LocalVarAccepts = @()
$LocalVarContentTypes = @()
$LocalVarQueryParameters = @{}
$LocalVarHeaderParameters = @{}
$LocalVarFormParameters = @{}
$LocalVarPathParameters = @{}
$LocalVarCookieParameters = @{}
$LocalVarBodyParameter = $null
$Configuration = Get-PSConfiguration
# HTTP header 'Content-Type'
$LocalVarContentTypes = @('application/x-www-form-urlencoded')
$LocalVarUri = '/pet/{petId}'
if (!$PetId) {
throw "Error! The required parameter `PetId` missing when calling updatePetWithForm."
}
$LocalVarUri = $LocalVarUri.replace('{petId}', $PetId)
if ($Name) {
$LocalVarFormParameters['name'] = $Name
}
if ($Status) {
$LocalVarFormParameters['status'] = $Status
}
$LocalVarResult = Invoke-PSApiClient -Method 'POST' `
-Uri $LocalVarUri `
-Accepts $LocalVarAccepts `
-ContentTypes $LocalVarContentTypes `
-Body $LocalVarBodyParameter `
-HeaderParameters $LocalVarHeaderParameters `
-QueryParameters $LocalVarQueryParameters `
-FormParameters $LocalVarFormParameters `
-CookieParameters $LocalVarCookieParameters `
-ReturnType ""
if ($WithHttpInfo.IsPresent) {
return $LocalVarResult
} else {
return $LocalVarResult["Response"]
}
}
}
<#
.SYNOPSIS
uploads an image
.DESCRIPTION
No description available.
.PARAMETER PetId
ID of pet to update
.PARAMETER AdditionalMetadata
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
#>
function Invoke-PSUploadFile {
[CmdletBinding()]
Param (
[Parameter(Position = 0, ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true, Mandatory = $false)]
[Int64]
${PetId},
[Parameter(Position = 1, ValueFromPipelineByPropertyName = $true, Mandatory = $false)]
[String]
${AdditionalMetadata},
[Parameter(Position = 2, ValueFromPipelineByPropertyName = $true, Mandatory = $false)]
[System.IO.FileInfo]
${File},
[Switch]
$WithHttpInfo
)
Process {
'Calling method: Invoke-PSUploadFile' | Write-Debug
$PSBoundParameters | Out-DebugParameter | Write-Debug
$LocalVarAccepts = @()
$LocalVarContentTypes = @()
$LocalVarQueryParameters = @{}
$LocalVarHeaderParameters = @{}
$LocalVarFormParameters = @{}
$LocalVarPathParameters = @{}
$LocalVarCookieParameters = @{}
$LocalVarBodyParameter = $null
$Configuration = Get-PSConfiguration
# HTTP header 'Accept' (if needed)
$LocalVarAccepts = @('application/json')
# HTTP header 'Content-Type'
$LocalVarContentTypes = @('multipart/form-data')
$LocalVarUri = '/pet/{petId}/uploadImage'
if (!$PetId) {
throw "Error! The required parameter `PetId` missing when calling uploadFile."
}
$LocalVarUri = $LocalVarUri.replace('{petId}', $PetId)
if ($AdditionalMetadata) {
$LocalVarFormParameters['additionalMetadata'] = $AdditionalMetadata
}
if ($File) {
$LocalVarFormParameters['file'] = $File
}
$LocalVarResult = Invoke-PSApiClient -Method 'POST' `
-Uri $LocalVarUri `
-Accepts $LocalVarAccepts `
-ContentTypes $LocalVarContentTypes `
-Body $LocalVarBodyParameter `
-HeaderParameters $LocalVarHeaderParameters `
-QueryParameters $LocalVarQueryParameters `
-FormParameters $LocalVarFormParameters `
-CookieParameters $LocalVarCookieParameters `
-ReturnType "ApiResponse"
if ($WithHttpInfo.IsPresent) {
return $LocalVarResult
} else {
return $LocalVarResult["Response"]
}
}
}

View File

@@ -0,0 +1,316 @@
#
# OpenAPI Petstore
# This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
# Version: 1.0.0
# Generated by OpenAPI Generator: https://openapi-generator.tech
#
<#
.SYNOPSIS
Delete purchase order by ID
.DESCRIPTION
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
#>
function Remove-PSOrder {
[CmdletBinding()]
Param (
[Parameter(Position = 0, ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true, Mandatory = $false)]
[String]
${OrderId},
[Switch]
$WithHttpInfo
)
Process {
'Calling method: Remove-PSOrder' | Write-Debug
$PSBoundParameters | Out-DebugParameter | Write-Debug
$LocalVarAccepts = @()
$LocalVarContentTypes = @()
$LocalVarQueryParameters = @{}
$LocalVarHeaderParameters = @{}
$LocalVarFormParameters = @{}
$LocalVarPathParameters = @{}
$LocalVarCookieParameters = @{}
$LocalVarBodyParameter = $null
$Configuration = Get-PSConfiguration
$LocalVarUri = '/store/order/{orderId}'
if (!$OrderId) {
throw "Error! The required parameter `OrderId` missing when calling deleteOrder."
}
$LocalVarUri = $LocalVarUri.replace('{orderId}', $OrderId)
$LocalVarResult = Invoke-PSApiClient -Method 'DELETE' `
-Uri $LocalVarUri `
-Accepts $LocalVarAccepts `
-ContentTypes $LocalVarContentTypes `
-Body $LocalVarBodyParameter `
-HeaderParameters $LocalVarHeaderParameters `
-QueryParameters $LocalVarQueryParameters `
-FormParameters $LocalVarFormParameters `
-CookieParameters $LocalVarCookieParameters `
-ReturnType ""
if ($WithHttpInfo.IsPresent) {
return $LocalVarResult
} else {
return $LocalVarResult["Response"]
}
}
}
<#
.SYNOPSIS
Returns pet inventories by status
.DESCRIPTION
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
#>
function Get-PSInventory {
[CmdletBinding()]
Param (
[Switch]
$WithHttpInfo
)
Process {
'Calling method: Get-PSInventory' | Write-Debug
$PSBoundParameters | Out-DebugParameter | Write-Debug
$LocalVarAccepts = @()
$LocalVarContentTypes = @()
$LocalVarQueryParameters = @{}
$LocalVarHeaderParameters = @{}
$LocalVarFormParameters = @{}
$LocalVarPathParameters = @{}
$LocalVarCookieParameters = @{}
$LocalVarBodyParameter = $null
$Configuration = Get-PSConfiguration
# HTTP header 'Accept' (if needed)
$LocalVarAccepts = @('application/json')
$LocalVarUri = '/store/inventory'
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' `
-Uri $LocalVarUri `
-Accepts $LocalVarAccepts `
-ContentTypes $LocalVarContentTypes `
-Body $LocalVarBodyParameter `
-HeaderParameters $LocalVarHeaderParameters `
-QueryParameters $LocalVarQueryParameters `
-FormParameters $LocalVarFormParameters `
-CookieParameters $LocalVarCookieParameters `
-ReturnType "System.Collections.Hashtable"
if ($WithHttpInfo.IsPresent) {
return $LocalVarResult
} else {
return $LocalVarResult["Response"]
}
}
}
<#
.SYNOPSIS
Find purchase order by ID
.DESCRIPTION
No description available.
.PARAMETER OrderId
ID of pet that needs to be fetched
.PARAMETER ReturnType
Select the return type (optional): application/xml, application/json
.PARAMETER WithHttpInfo
A switch when turned on will return a hash table of Response, StatusCode and Headers instead of just the Response
.OUTPUTS
Order
#>
function Get-PSOrderById {
[CmdletBinding()]
Param (
[Parameter(Position = 0, ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true, Mandatory = $false)]
[Int64]
${OrderId},
[String]
[ValidateSet("application/xml", "application/json")]
$ReturnType,
[Switch]
$WithHttpInfo
)
Process {
'Calling method: Get-PSOrderById' | Write-Debug
$PSBoundParameters | Out-DebugParameter | Write-Debug
$LocalVarAccepts = @()
$LocalVarContentTypes = @()
$LocalVarQueryParameters = @{}
$LocalVarHeaderParameters = @{}
$LocalVarFormParameters = @{}
$LocalVarPathParameters = @{}
$LocalVarCookieParameters = @{}
$LocalVarBodyParameter = $null
$Configuration = Get-PSConfiguration
# HTTP header 'Accept' (if needed)
$LocalVarAccepts = @('application/xml', 'application/json')
if ($ReturnType) {
# use the return type (MIME) provided by the user
$LocalVarAccepts = @($ReturnType)
}
$LocalVarUri = '/store/order/{orderId}'
if (!$OrderId) {
throw "Error! The required parameter `OrderId` missing when calling getOrderById."
}
$LocalVarUri = $LocalVarUri.replace('{orderId}', $OrderId)
$LocalVarResult = Invoke-PSApiClient -Method 'GET' `
-Uri $LocalVarUri `
-Accepts $LocalVarAccepts `
-ContentTypes $LocalVarContentTypes `
-Body $LocalVarBodyParameter `
-HeaderParameters $LocalVarHeaderParameters `
-QueryParameters $LocalVarQueryParameters `
-FormParameters $LocalVarFormParameters `
-CookieParameters $LocalVarCookieParameters `
-ReturnType "Order"
if ($WithHttpInfo.IsPresent) {
return $LocalVarResult
} else {
return $LocalVarResult["Response"]
}
}
}
<#
.SYNOPSIS
Place an order for a pet
.DESCRIPTION
No description available.
.PARAMETER Order
order placed for purchasing the pet
.PARAMETER ReturnType
Select the return type (optional): application/xml, application/json
.PARAMETER WithHttpInfo
A switch when turned on will return a hash table of Response, StatusCode and Headers instead of just the Response
.OUTPUTS
Order
#>
function Invoke-PSPlaceOrder {
[CmdletBinding()]
Param (
[Parameter(Position = 0, ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true, Mandatory = $false)]
[PSCustomObject]
${Order},
[String]
[ValidateSet("application/xml", "application/json")]
$ReturnType,
[Switch]
$WithHttpInfo
)
Process {
'Calling method: Invoke-PSPlaceOrder' | Write-Debug
$PSBoundParameters | Out-DebugParameter | Write-Debug
$LocalVarAccepts = @()
$LocalVarContentTypes = @()
$LocalVarQueryParameters = @{}
$LocalVarHeaderParameters = @{}
$LocalVarFormParameters = @{}
$LocalVarPathParameters = @{}
$LocalVarCookieParameters = @{}
$LocalVarBodyParameter = $null
$Configuration = Get-PSConfiguration
# HTTP header 'Accept' (if needed)
$LocalVarAccepts = @('application/xml', 'application/json')
if ($ReturnType) {
# use the return type (MIME) provided by the user
$LocalVarAccepts = @($ReturnType)
}
# HTTP header 'Content-Type'
$LocalVarContentTypes = @('application/json')
$LocalVarUri = '/store/order'
if (!$Order) {
throw "Error! The required parameter `Order` missing when calling placeOrder."
}
$LocalVarBodyParameter = $Order | ConvertTo-Json
$LocalVarResult = Invoke-PSApiClient -Method 'POST' `
-Uri $LocalVarUri `
-Accepts $LocalVarAccepts `
-ContentTypes $LocalVarContentTypes `
-Body $LocalVarBodyParameter `
-HeaderParameters $LocalVarHeaderParameters `
-QueryParameters $LocalVarQueryParameters `
-FormParameters $LocalVarFormParameters `
-CookieParameters $LocalVarCookieParameters `
-ReturnType "Order"
if ($WithHttpInfo.IsPresent) {
return $LocalVarResult
} else {
return $LocalVarResult["Response"]
}
}
}

View File

@@ -0,0 +1,651 @@
#
# OpenAPI Petstore
# This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
# Version: 1.0.0
# Generated by OpenAPI Generator: https://openapi-generator.tech
#
<#
.SYNOPSIS
Create user
.DESCRIPTION
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
#>
function New-PSUser {
[CmdletBinding()]
Param (
[Parameter(Position = 0, ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true, Mandatory = $false)]
[PSCustomObject]
${User},
[Switch]
$WithHttpInfo
)
Process {
'Calling method: New-PSUser' | Write-Debug
$PSBoundParameters | Out-DebugParameter | Write-Debug
$LocalVarAccepts = @()
$LocalVarContentTypes = @()
$LocalVarQueryParameters = @{}
$LocalVarHeaderParameters = @{}
$LocalVarFormParameters = @{}
$LocalVarPathParameters = @{}
$LocalVarCookieParameters = @{}
$LocalVarBodyParameter = $null
$Configuration = Get-PSConfiguration
# HTTP header 'Content-Type'
$LocalVarContentTypes = @('application/json')
$LocalVarUri = '/user'
if (!$User) {
throw "Error! The required parameter `User` missing when calling createUser."
}
$LocalVarBodyParameter = $User | ConvertTo-Json
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' `
-Uri $LocalVarUri `
-Accepts $LocalVarAccepts `
-ContentTypes $LocalVarContentTypes `
-Body $LocalVarBodyParameter `
-HeaderParameters $LocalVarHeaderParameters `
-QueryParameters $LocalVarQueryParameters `
-FormParameters $LocalVarFormParameters `
-CookieParameters $LocalVarCookieParameters `
-ReturnType ""
if ($WithHttpInfo.IsPresent) {
return $LocalVarResult
} else {
return $LocalVarResult["Response"]
}
}
}
<#
.SYNOPSIS
Creates list of users with given input array
.DESCRIPTION
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
#>
function New-PSUsersWithArrayInput {
[CmdletBinding()]
Param (
[Parameter(Position = 0, ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true, Mandatory = $false)]
[PSCustomObject[]]
${User},
[Switch]
$WithHttpInfo
)
Process {
'Calling method: New-PSUsersWithArrayInput' | Write-Debug
$PSBoundParameters | Out-DebugParameter | Write-Debug
$LocalVarAccepts = @()
$LocalVarContentTypes = @()
$LocalVarQueryParameters = @{}
$LocalVarHeaderParameters = @{}
$LocalVarFormParameters = @{}
$LocalVarPathParameters = @{}
$LocalVarCookieParameters = @{}
$LocalVarBodyParameter = $null
$Configuration = Get-PSConfiguration
# HTTP header 'Content-Type'
$LocalVarContentTypes = @('application/json')
$LocalVarUri = '/user/createWithArray'
if (!$User) {
throw "Error! The required parameter `User` missing when calling createUsersWithArrayInput."
}
$LocalVarBodyParameter = $User | ConvertTo-Json
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' `
-Uri $LocalVarUri `
-Accepts $LocalVarAccepts `
-ContentTypes $LocalVarContentTypes `
-Body $LocalVarBodyParameter `
-HeaderParameters $LocalVarHeaderParameters `
-QueryParameters $LocalVarQueryParameters `
-FormParameters $LocalVarFormParameters `
-CookieParameters $LocalVarCookieParameters `
-ReturnType ""
if ($WithHttpInfo.IsPresent) {
return $LocalVarResult
} else {
return $LocalVarResult["Response"]
}
}
}
<#
.SYNOPSIS
Creates list of users with given input array
.DESCRIPTION
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
#>
function New-PSUsersWithListInput {
[CmdletBinding()]
Param (
[Parameter(Position = 0, ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true, Mandatory = $false)]
[PSCustomObject[]]
${User},
[Switch]
$WithHttpInfo
)
Process {
'Calling method: New-PSUsersWithListInput' | Write-Debug
$PSBoundParameters | Out-DebugParameter | Write-Debug
$LocalVarAccepts = @()
$LocalVarContentTypes = @()
$LocalVarQueryParameters = @{}
$LocalVarHeaderParameters = @{}
$LocalVarFormParameters = @{}
$LocalVarPathParameters = @{}
$LocalVarCookieParameters = @{}
$LocalVarBodyParameter = $null
$Configuration = Get-PSConfiguration
# HTTP header 'Content-Type'
$LocalVarContentTypes = @('application/json')
$LocalVarUri = '/user/createWithList'
if (!$User) {
throw "Error! The required parameter `User` missing when calling createUsersWithListInput."
}
$LocalVarBodyParameter = $User | ConvertTo-Json
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' `
-Uri $LocalVarUri `
-Accepts $LocalVarAccepts `
-ContentTypes $LocalVarContentTypes `
-Body $LocalVarBodyParameter `
-HeaderParameters $LocalVarHeaderParameters `
-QueryParameters $LocalVarQueryParameters `
-FormParameters $LocalVarFormParameters `
-CookieParameters $LocalVarCookieParameters `
-ReturnType ""
if ($WithHttpInfo.IsPresent) {
return $LocalVarResult
} else {
return $LocalVarResult["Response"]
}
}
}
<#
.SYNOPSIS
Delete user
.DESCRIPTION
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
#>
function Remove-PSUser {
[CmdletBinding()]
Param (
[Parameter(Position = 0, ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true, Mandatory = $false)]
[String]
${Username},
[Switch]
$WithHttpInfo
)
Process {
'Calling method: Remove-PSUser' | Write-Debug
$PSBoundParameters | Out-DebugParameter | Write-Debug
$LocalVarAccepts = @()
$LocalVarContentTypes = @()
$LocalVarQueryParameters = @{}
$LocalVarHeaderParameters = @{}
$LocalVarFormParameters = @{}
$LocalVarPathParameters = @{}
$LocalVarCookieParameters = @{}
$LocalVarBodyParameter = $null
$Configuration = Get-PSConfiguration
$LocalVarUri = '/user/{username}'
if (!$Username) {
throw "Error! The required parameter `Username` missing when calling deleteUser."
}
$LocalVarUri = $LocalVarUri.replace('{username}', $Username)
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' `
-Uri $LocalVarUri `
-Accepts $LocalVarAccepts `
-ContentTypes $LocalVarContentTypes `
-Body $LocalVarBodyParameter `
-HeaderParameters $LocalVarHeaderParameters `
-QueryParameters $LocalVarQueryParameters `
-FormParameters $LocalVarFormParameters `
-CookieParameters $LocalVarCookieParameters `
-ReturnType ""
if ($WithHttpInfo.IsPresent) {
return $LocalVarResult
} else {
return $LocalVarResult["Response"]
}
}
}
<#
.SYNOPSIS
Get user by user name
.DESCRIPTION
No description available.
.PARAMETER Username
The name that needs to be fetched. Use user1 for testing.
.PARAMETER ReturnType
Select the return type (optional): application/xml, application/json
.PARAMETER WithHttpInfo
A switch when turned on will return a hash table of Response, StatusCode and Headers instead of just the Response
.OUTPUTS
User
#>
function Get-PSUserByName {
[CmdletBinding()]
Param (
[Parameter(Position = 0, ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true, Mandatory = $false)]
[String]
${Username},
[String]
[ValidateSet("application/xml", "application/json")]
$ReturnType,
[Switch]
$WithHttpInfo
)
Process {
'Calling method: Get-PSUserByName' | Write-Debug
$PSBoundParameters | Out-DebugParameter | Write-Debug
$LocalVarAccepts = @()
$LocalVarContentTypes = @()
$LocalVarQueryParameters = @{}
$LocalVarHeaderParameters = @{}
$LocalVarFormParameters = @{}
$LocalVarPathParameters = @{}
$LocalVarCookieParameters = @{}
$LocalVarBodyParameter = $null
$Configuration = Get-PSConfiguration
# HTTP header 'Accept' (if needed)
$LocalVarAccepts = @('application/xml', 'application/json')
if ($ReturnType) {
# use the return type (MIME) provided by the user
$LocalVarAccepts = @($ReturnType)
}
$LocalVarUri = '/user/{username}'
if (!$Username) {
throw "Error! The required parameter `Username` missing when calling getUserByName."
}
$LocalVarUri = $LocalVarUri.replace('{username}', $Username)
$LocalVarResult = Invoke-PSApiClient -Method 'GET' `
-Uri $LocalVarUri `
-Accepts $LocalVarAccepts `
-ContentTypes $LocalVarContentTypes `
-Body $LocalVarBodyParameter `
-HeaderParameters $LocalVarHeaderParameters `
-QueryParameters $LocalVarQueryParameters `
-FormParameters $LocalVarFormParameters `
-CookieParameters $LocalVarCookieParameters `
-ReturnType "User"
if ($WithHttpInfo.IsPresent) {
return $LocalVarResult
} else {
return $LocalVarResult["Response"]
}
}
}
<#
.SYNOPSIS
Logs user into the system
.DESCRIPTION
No description available.
.PARAMETER Username
The user name for login
.PARAMETER Password
The password for login in clear text
.PARAMETER ReturnType
Select the return type (optional): application/xml, application/json
.PARAMETER WithHttpInfo
A switch when turned on will return a hash table of Response, StatusCode and Headers instead of just the Response
.OUTPUTS
String
#>
function Invoke-PSLoginUser {
[CmdletBinding()]
Param (
[Parameter(Position = 0, ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true, Mandatory = $false)]
[String]
${Username},
[Parameter(Position = 1, ValueFromPipelineByPropertyName = $true, Mandatory = $false)]
[String]
${Password},
[String]
[ValidateSet("application/xml", "application/json")]
$ReturnType,
[Switch]
$WithHttpInfo
)
Process {
'Calling method: Invoke-PSLoginUser' | Write-Debug
$PSBoundParameters | Out-DebugParameter | Write-Debug
$LocalVarAccepts = @()
$LocalVarContentTypes = @()
$LocalVarQueryParameters = @{}
$LocalVarHeaderParameters = @{}
$LocalVarFormParameters = @{}
$LocalVarPathParameters = @{}
$LocalVarCookieParameters = @{}
$LocalVarBodyParameter = $null
$Configuration = Get-PSConfiguration
# HTTP header 'Accept' (if needed)
$LocalVarAccepts = @('application/xml', 'application/json')
if ($ReturnType) {
# use the return type (MIME) provided by the user
$LocalVarAccepts = @($ReturnType)
}
$LocalVarUri = '/user/login'
if (!$Username) {
throw "Error! The required parameter `Username` missing when calling loginUser."
}
$LocalVarQueryParameters['username'] = $Username
if (!$Password) {
throw "Error! The required parameter `Password` missing when calling loginUser."
}
$LocalVarQueryParameters['password'] = $Password
$LocalVarResult = Invoke-PSApiClient -Method 'GET' `
-Uri $LocalVarUri `
-Accepts $LocalVarAccepts `
-ContentTypes $LocalVarContentTypes `
-Body $LocalVarBodyParameter `
-HeaderParameters $LocalVarHeaderParameters `
-QueryParameters $LocalVarQueryParameters `
-FormParameters $LocalVarFormParameters `
-CookieParameters $LocalVarCookieParameters `
-ReturnType "String"
if ($WithHttpInfo.IsPresent) {
return $LocalVarResult
} else {
return $LocalVarResult["Response"]
}
}
}
<#
.SYNOPSIS
Logs out current logged in user session
.DESCRIPTION
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
#>
function Invoke-PSLogoutUser {
[CmdletBinding()]
Param (
[Switch]
$WithHttpInfo
)
Process {
'Calling method: Invoke-PSLogoutUser' | Write-Debug
$PSBoundParameters | Out-DebugParameter | Write-Debug
$LocalVarAccepts = @()
$LocalVarContentTypes = @()
$LocalVarQueryParameters = @{}
$LocalVarHeaderParameters = @{}
$LocalVarFormParameters = @{}
$LocalVarPathParameters = @{}
$LocalVarCookieParameters = @{}
$LocalVarBodyParameter = $null
$Configuration = Get-PSConfiguration
$LocalVarUri = '/user/logout'
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' `
-Uri $LocalVarUri `
-Accepts $LocalVarAccepts `
-ContentTypes $LocalVarContentTypes `
-Body $LocalVarBodyParameter `
-HeaderParameters $LocalVarHeaderParameters `
-QueryParameters $LocalVarQueryParameters `
-FormParameters $LocalVarFormParameters `
-CookieParameters $LocalVarCookieParameters `
-ReturnType ""
if ($WithHttpInfo.IsPresent) {
return $LocalVarResult
} else {
return $LocalVarResult["Response"]
}
}
}
<#
.SYNOPSIS
Updated user
.DESCRIPTION
No description available.
.PARAMETER Username
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
#>
function Update-PSUser {
[CmdletBinding()]
Param (
[Parameter(Position = 0, ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true, Mandatory = $false)]
[String]
${Username},
[Parameter(Position = 1, ValueFromPipelineByPropertyName = $true, Mandatory = $false)]
[PSCustomObject]
${User},
[Switch]
$WithHttpInfo
)
Process {
'Calling method: Update-PSUser' | Write-Debug
$PSBoundParameters | Out-DebugParameter | Write-Debug
$LocalVarAccepts = @()
$LocalVarContentTypes = @()
$LocalVarQueryParameters = @{}
$LocalVarHeaderParameters = @{}
$LocalVarFormParameters = @{}
$LocalVarPathParameters = @{}
$LocalVarCookieParameters = @{}
$LocalVarBodyParameter = $null
$Configuration = Get-PSConfiguration
# HTTP header 'Content-Type'
$LocalVarContentTypes = @('application/json')
$LocalVarUri = '/user/{username}'
if (!$Username) {
throw "Error! The required parameter `Username` missing when calling updateUser."
}
$LocalVarUri = $LocalVarUri.replace('{username}', $Username)
if (!$User) {
throw "Error! The required parameter `User` missing when calling updateUser."
}
$LocalVarBodyParameter = $User | ConvertTo-Json
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' `
-Uri $LocalVarUri `
-Accepts $LocalVarAccepts `
-ContentTypes $LocalVarContentTypes `
-Body $LocalVarBodyParameter `
-HeaderParameters $LocalVarHeaderParameters `
-QueryParameters $LocalVarQueryParameters `
-FormParameters $LocalVarFormParameters `
-CookieParameters $LocalVarCookieParameters `
-ReturnType ""
if ($WithHttpInfo.IsPresent) {
return $LocalVarResult
} else {
return $LocalVarResult["Response"]
}
}
}

View File

@@ -0,0 +1,391 @@
#
# OpenAPI Petstore
# This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
# Version: 1.0.0
# Generated by OpenAPI Generator: https://openapi-generator.tech
#
<#
.SYNOPSIS
Get the configuration object 'PSConfiguration'.
.DESCRIPTION
Get the configuration object 'PSConfiguration'.
.OUTPUTS
System.Collections.Hashtable
#>
function Get-PSConfiguration {
$Configuration = $Script:Configuration
if ([string]::IsNullOrEmpty($Configuration["BaseUrl"])) {
$Configuration["BaseUrl"] = "http://petstore.swagger.io:80/v2";
}
if (!$Configuration.containsKey("Username")) {
$Configuration["Username"] = $null
}
if (!$Configuration.containsKey("Password")) {
$Configuration["Password"] = $null
}
if (!$Configuration.containsKey("AccessToken")) {
$Configuration["AccessToken"] = $null
}
if (!$Configuration.containsKey("Cookie")) {
$Configuration["Cookie"] = $null
}
if (!$Configuration["DefaultHeaders"]) {
$Configuration["DefaultHeaders"] = @{}
}
if (!$Configuration["ApiKey"]) {
$Configuration["ApiKey"] = @{}
}
if (!$Configuration["ApiKeyPrefix"]) {
$Configuration["ApiKeyPrefix"] = @{}
}
if (!$Configuration.containsKey("SkipCertificateCheck")) {
$Configuration["SkipCertificateCheck"] = $false
}
Return $Configuration
}
<#
.SYNOPSIS
Set the configuration.
.DESCRIPTION
Set the configuration.
.PARAMETER BaseUrl
Base URL of the HTTP endpoints
.PARAMETER Username
Username in HTTP basic authentication
.PARAMETER Passowrd
Password in HTTP basic authentication
.PARAMETER ApiKey
API Keys for authentication/authorization
.PARAMETER ApiKeyPrefix
Prefix in the API Keys
.PARAMETER Cookie
Cookie for authentication/authorization
.PARAMETER AccessToken
Access token for authentication/authorization
.PARAMETER SkipCertificateCheck
Skip certificate verification
.PARAMETER DefaultHeaders
Default HTTP headers to be included in the HTTP request
.PARAMETER PassThru
Return an object of the Configuration
.OUTPUTS
System.Collections.Hashtable
#>
function Set-PSConfiguration {
[CmdletBinding()]
Param(
[string]$BaseUrl,
[AllowEmptyString()]
[string]$Username,
[AllowEmptyString()]
[string]$Password,
[hashtable]$ApiKey,
[hashtable]$ApiKeyPrefix,
[AllowEmptyString()]
[string]$Cookie,
[AllowEmptyString()]
[string]$AccessToken,
[switch]$SkipCertificateCheck,
[hashtable]$DefaultHeaders,
[switch]$PassThru
)
Process {
If ($BaseUrl) {
# validate URL
$URL = $BaseUrl -as [System.URI]
if (!($null -ne $URL.AbsoluteURI -and $URL.Scheme -match '[http|https]')) {
throw "Invalid URL '$($BaseUrl)' cannot be used in the base URL."
}
$Script:Configuration["BaseUrl"] = $BaseUrl
}
If ($Username) {
$Script:Configuration['Username'] = $Username
}
If ($Password) {
$Script:Configuration['Password'] = $Password
}
If ($ApiKey) {
$Script:Configuration['ApiKey'] = $ApiKey
}
If ($ApiKeyPrefix) {
$Script:Configuration['ApiKeyPrefix'] = $ApiKeyPrefix
}
If ($Cookie) {
$Script:Configuration['Cookie'] = $Cookie
}
If ($AccessToken) {
$Script:Configuration['AccessToken'] = $AccessToken
}
If ($SkipCertificateCheck.IsPresent) {
$Script:Configuration['SkipCertificateCheck'] = $true
} else {
$Script:Configuration['SkipCertificateCheck'] = $false
}
If ($DefaultHeaders) {
$Script:Configuration['DefaultHeaders'] = $DefaultHeaders
}
If ($PassThru.IsPresent) {
$Script:Configuration
}
}
}
<#
.SYNOPSIS
Set the API Key.
.DESCRIPTION
Set the API Key.
.PARAMETER Id
ID of the security schema
.PARAMETER ApiKey
API Key
.OUTPUTS
None
#>
function Set-PSConfigurationApiKey {
[CmdletBinding()]
Param(
[string]$Id,
[AllowEmptyString()]
[string]$ApiKey
)
Process {
if (!$Script:Configuration["ApiKey"]) {
$Script:Configuration["ApiKey"] = @{}
}
$Script:Configuration["ApiKey"][$Id] = $ApiKey
}
}
<#
.SYNOPSIS
Set the API Key prefix.
.DESCRIPTION
Set the API Key prefix.
.PARAMETER Id
ID of the security schema
.PARAMETER ApiKey
API Key prefix
.OUTPUTS
None
#>
function Set-PSConfigurationApiKeyPrefix {
[CmdletBinding()]
Param(
[string]$Id,
[AllowEmptyString()]
[string]$ApiKeyPrefix
)
Process {
if (!$Script:Configuration["ApiKeyPrefix"]) {
$Script:Configuration["ApiKeyPrefix"] = @{}
}
$Script:Configuration["ApiKeyPrefix"][$Id] = $ApiKeyPrefix
}
}
<#
.SYNOPSIS
Set the default header.
.DESCRIPTION
Set the default header.
.PARAMETER Key
Key of the HTTP header
.PARAMETER Value
Value of the HTTP header
.OUTPUTS
None
#>
function Set-PSConfigurationDefaultHeader {
[CmdletBinding()]
Param(
[string]$Key,
[AllowEmptyString()]
[string]$Value
)
Process {
if (!$Script:Configuration["DefaultHeaders"]) {
$Script:Configuration["DefaultHeaders"] = @{}
}
$Script:Configuration["DefaultHeaders"][$Key] = $Value
}
}
<#
.SYNOPSIS
Get the host setting.
.DESCRIPTION
Get the host setting in the form of array of hashtables.
.OUTPUTS
System.Collections.Hashtable[]
#>
function Get-PSHostSetting {
return ,@(
@{
"Url" = "http://{server}.swagger.io:{port}/v2";
"Description" = "petstore server";
"Variables" = @{
"server" = @{
"Description" = "No description provided";
"DefaultValue" = "petstore";
"EnumValues" = @(
"petstore",
"qa-petstore",
"dev-petstore"
)
};
"port" = @{
"Description" = "No description provided";
"DefaultValue" = "80";
"EnumValues" = @(
"80",
"8080"
)
}
}
},
@{
"Url" = "https://localhost:8080/{version}";
"Description" = "The local server";
"Variables" = @{
"version" = @{
"Description" = "No description provided";
"DefaultValue" = "v2";
"EnumValues" = @(
"v1",
"v2"
)
}
}
}
)
}
<#
.SYNOPSIS
Get the URL from the host settings.
.PARAMETER Index
Index of the host settings (array)
.PARAMETER Variables
Names and values of the variables (hashtable)
.DESCRIPTION
Get the URL from the host settings.
.OUTPUTS
String
#>
function Get-PSUrlFromHostSetting {
[CmdletBinding()]
Param(
[Parameter(ValueFromPipeline = $true)]
[Int]$Index,
[Hashtable]$Variables = @{}
)
Process {
$Hosts = Get-PSHostSetting
# check array index out of bound
if ($Index -lt 0 -or $Index -ge $Hosts.Length) {
throw "Invalid index $index when selecting the host. Must be less than $($Hosts.Length)"
}
$MyHost = $Hosts[$Index];
$Url = $MyHost["Url"];
# go through variable and assign a value
foreach ($h in $MyHost["Variables"].GetEnumerator()) {
if ($Variables.containsKey($h.Name)) { # check to see if it's in the variables provided by the user
if ($h.Value["EnumValues"] -Contains $Variables[$h.Name]) {
$Url = $Url.replace("{$($h.Name)}", $Variables[$h.Name])
} else {
throw "The variable '$($h.Name)' in the host URL has invalid value $($Variables[$h.Name]). Must be $($h.Value["EnumValues"] -join ",")"
}
} else {
$Url = $Url.replace("{$($h.Name)}", $h.Value["DefaultValue"])
}
}
return $Url;
}
}

View File

@@ -0,0 +1,57 @@
#
# OpenAPI Petstore
# This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
# Version: 1.0.0
# Generated by OpenAPI Generator: https://openapi-generator.tech
#
<#
.SYNOPSIS
No summary available.
.DESCRIPTION
Describes the result of uploading an image resource
.PARAMETER Code
No description available.
.PARAMETER Type
No description available.
.PARAMETER Message
No description available.
.OUTPUTS
ApiResponse<PSCustomObject>
#>
function Initialize-PSApiResponse {
[CmdletBinding()]
Param (
[Parameter(Position = 0, ValueFromPipelineByPropertyName = $true)]
[System.Nullable[Int32]]
${Code},
[Parameter(Position = 1, ValueFromPipelineByPropertyName = $true)]
[String]
${Type},
[Parameter(Position = 2, ValueFromPipelineByPropertyName = $true)]
[String]
${Message}
)
Process {
'Creating PSCustomObject: PSPetstore => PSApiResponse' | Write-Debug
$PSBoundParameters | Out-DebugParameter | Write-Debug
$PSO = [PSCustomObject]@{
"code" = ${Code}
"type" = ${Type}
"message" = ${Message}
}
return $PSO
}
}

View File

@@ -0,0 +1,51 @@
#
# OpenAPI Petstore
# This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
# Version: 1.0.0
# Generated by OpenAPI Generator: https://openapi-generator.tech
#
<#
.SYNOPSIS
No summary available.
.DESCRIPTION
A category for a pet
.PARAMETER Id
No description available.
.PARAMETER Name
No description available.
.OUTPUTS
Category<PSCustomObject>
#>
function Initialize-PSCategory {
[CmdletBinding()]
Param (
[Parameter(Position = 0, ValueFromPipelineByPropertyName = $true)]
[System.Nullable[Int64]]
${Id},
[Parameter(Position = 1, ValueFromPipelineByPropertyName = $true)]
[ValidatePattern("^[a-zA-Z0-9]+[a-zA-Z0-9\\.\\-_]*[a-zA-Z0-9]+$")]
[String]
${Name}
)
Process {
'Creating PSCustomObject: PSPetstore => PSCategory' | Write-Debug
$PSBoundParameters | Out-DebugParameter | Write-Debug
$PSO = [PSCustomObject]@{
"id" = ${Id}
"name" = ${Name}
}
return $PSO
}
}

View File

@@ -0,0 +1,50 @@
#
# OpenAPI Petstore
# This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
# Version: 1.0.0
# Generated by OpenAPI Generator: https://openapi-generator.tech
#
<#
.SYNOPSIS
No summary available.
.DESCRIPTION
No description available.
.PARAMETER Name
Updated name of the pet
.PARAMETER Status
Updated status of the pet
.OUTPUTS
InlineObject<PSCustomObject>
#>
function Initialize-PSInlineObject {
[CmdletBinding()]
Param (
[Parameter(Position = 0, ValueFromPipelineByPropertyName = $true)]
[String]
${Name},
[Parameter(Position = 1, ValueFromPipelineByPropertyName = $true)]
[String]
${Status}
)
Process {
'Creating PSCustomObject: PSPetstore => PSInlineObject' | Write-Debug
$PSBoundParameters | Out-DebugParameter | Write-Debug
$PSO = [PSCustomObject]@{
"name" = ${Name}
"status" = ${Status}
}
return $PSO
}
}

View File

@@ -0,0 +1,50 @@
#
# OpenAPI Petstore
# This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
# Version: 1.0.0
# Generated by OpenAPI Generator: https://openapi-generator.tech
#
<#
.SYNOPSIS
No summary available.
.DESCRIPTION
No description available.
.PARAMETER AdditionalMetadata
Additional data to pass to server
.PARAMETER File
file to upload
.OUTPUTS
InlineObject1<PSCustomObject>
#>
function Initialize-PSInlineObject1 {
[CmdletBinding()]
Param (
[Parameter(Position = 0, ValueFromPipelineByPropertyName = $true)]
[String]
${AdditionalMetadata},
[Parameter(Position = 1, ValueFromPipelineByPropertyName = $true)]
[System.IO.FileInfo]
${File}
)
Process {
'Creating PSCustomObject: PSPetstore => PSInlineObject1' | Write-Debug
$PSBoundParameters | Out-DebugParameter | Write-Debug
$PSO = [PSCustomObject]@{
"additionalMetadata" = ${AdditionalMetadata}
"file" = ${File}
}
return $PSO
}
}

View File

@@ -0,0 +1,79 @@
#
# OpenAPI Petstore
# This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
# Version: 1.0.0
# Generated by OpenAPI Generator: https://openapi-generator.tech
#
<#
.SYNOPSIS
No summary available.
.DESCRIPTION
An order for a pets from the pet store
.PARAMETER Id
No description available.
.PARAMETER PetId
No description available.
.PARAMETER Quantity
No description available.
.PARAMETER ShipDate
No description available.
.PARAMETER Status
Order Status
.PARAMETER Complete
No description available.
.OUTPUTS
Order<PSCustomObject>
#>
function Initialize-PSOrder {
[CmdletBinding()]
Param (
[Parameter(Position = 0, ValueFromPipelineByPropertyName = $true)]
[System.Nullable[Int64]]
${Id},
[Parameter(Position = 1, ValueFromPipelineByPropertyName = $true)]
[System.Nullable[Int64]]
${PetId},
[Parameter(Position = 2, ValueFromPipelineByPropertyName = $true)]
[System.Nullable[Int32]]
${Quantity},
[Parameter(Position = 3, ValueFromPipelineByPropertyName = $true)]
[System.Nullable[System.DateTime]]
${ShipDate},
[Parameter(Position = 4, ValueFromPipelineByPropertyName = $true)]
[ValidateSet("placed", "approved", "delivered")]
[String]
${Status},
[Parameter(Position = 5, ValueFromPipelineByPropertyName = $true)]
[System.Nullable[Boolean]]
${Complete}
)
Process {
'Creating PSCustomObject: PSPetstore => PSOrder' | Write-Debug
$PSBoundParameters | Out-DebugParameter | Write-Debug
$PSO = [PSCustomObject]@{
"id" = ${Id}
"petId" = ${PetId}
"quantity" = ${Quantity}
"shipDate" = ${ShipDate}
"status" = ${Status}
"complete" = ${Complete}
}
return $PSO
}
}

View File

@@ -0,0 +1,87 @@
#
# OpenAPI Petstore
# This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
# Version: 1.0.0
# Generated by OpenAPI Generator: https://openapi-generator.tech
#
<#
.SYNOPSIS
No summary available.
.DESCRIPTION
A pet for sale in the pet store
.PARAMETER Id
No description available.
.PARAMETER Category
No description available.
.PARAMETER Name
No description available.
.PARAMETER PhotoUrls
No description available.
.PARAMETER Tags
No description available.
.PARAMETER Status
pet status in the store
.OUTPUTS
Pet<PSCustomObject>
#>
function Initialize-PSPet {
[CmdletBinding()]
Param (
[Parameter(Position = 0, ValueFromPipelineByPropertyName = $true)]
[System.Nullable[Int64]]
${Id},
[Parameter(Position = 1, ValueFromPipelineByPropertyName = $true)]
[PSCustomObject]
${Category},
[Parameter(Position = 2, ValueFromPipelineByPropertyName = $true)]
[String]
${Name},
[Parameter(Position = 3, ValueFromPipelineByPropertyName = $true)]
[String[]]
${PhotoUrls},
[Parameter(Position = 4, ValueFromPipelineByPropertyName = $true)]
[PSCustomObject[]]
${Tags},
[Parameter(Position = 5, ValueFromPipelineByPropertyName = $true)]
[ValidateSet("available", "pending", "sold")]
[String]
${Status}
)
Process {
'Creating PSCustomObject: PSPetstore => PSPet' | Write-Debug
$PSBoundParameters | Out-DebugParameter | Write-Debug
if (!$Name) {
throw "invalid value for 'Name', 'Name' cannot be null."
}
if (!$PhotoUrls) {
throw "invalid value for 'PhotoUrls', 'PhotoUrls' cannot be null."
}
$PSO = [PSCustomObject]@{
"id" = ${Id}
"category" = ${Category}
"name" = ${Name}
"photoUrls" = ${PhotoUrls}
"tags" = ${Tags}
"status" = ${Status}
}
return $PSO
}
}

View File

@@ -0,0 +1,50 @@
#
# OpenAPI Petstore
# This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
# Version: 1.0.0
# Generated by OpenAPI Generator: https://openapi-generator.tech
#
<#
.SYNOPSIS
No summary available.
.DESCRIPTION
A tag for a pet
.PARAMETER Id
No description available.
.PARAMETER Name
No description available.
.OUTPUTS
Tag<PSCustomObject>
#>
function Initialize-PSTag {
[CmdletBinding()]
Param (
[Parameter(Position = 0, ValueFromPipelineByPropertyName = $true)]
[System.Nullable[Int64]]
${Id},
[Parameter(Position = 1, ValueFromPipelineByPropertyName = $true)]
[String]
${Name}
)
Process {
'Creating PSCustomObject: PSPetstore => PSTag' | Write-Debug
$PSBoundParameters | Out-DebugParameter | Write-Debug
$PSO = [PSCustomObject]@{
"id" = ${Id}
"name" = ${Name}
}
return $PSO
}
}

View File

@@ -0,0 +1,93 @@
#
# OpenAPI Petstore
# This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
# Version: 1.0.0
# Generated by OpenAPI Generator: https://openapi-generator.tech
#
<#
.SYNOPSIS
No summary available.
.DESCRIPTION
A User who is purchasing from the pet store
.PARAMETER Id
No description available.
.PARAMETER Username
No description available.
.PARAMETER FirstName
No description available.
.PARAMETER LastName
No description available.
.PARAMETER Email
No description available.
.PARAMETER Password
No description available.
.PARAMETER Phone
No description available.
.PARAMETER UserStatus
User Status
.OUTPUTS
User<PSCustomObject>
#>
function Initialize-PSUser {
[CmdletBinding()]
Param (
[Parameter(Position = 0, ValueFromPipelineByPropertyName = $true)]
[System.Nullable[Int64]]
${Id},
[Parameter(Position = 1, ValueFromPipelineByPropertyName = $true)]
[String]
${Username},
[Parameter(Position = 2, ValueFromPipelineByPropertyName = $true)]
[String]
${FirstName},
[Parameter(Position = 3, ValueFromPipelineByPropertyName = $true)]
[String]
${LastName},
[Parameter(Position = 4, ValueFromPipelineByPropertyName = $true)]
[String]
${Email},
[Parameter(Position = 5, ValueFromPipelineByPropertyName = $true)]
[ValidatePattern("[""A-Z]+-[0-9][0-9]")]
[String]
${Password},
[Parameter(Position = 6, ValueFromPipelineByPropertyName = $true)]
[String]
${Phone},
[Parameter(Position = 7, ValueFromPipelineByPropertyName = $true)]
[System.Nullable[Int32]]
${UserStatus}
)
Process {
'Creating PSCustomObject: PSPetstore => PSUser' | Write-Debug
$PSBoundParameters | Out-DebugParameter | Write-Debug
$PSO = [PSCustomObject]@{
"id" = ${Id}
"username" = ${Username}
"firstName" = ${FirstName}
"lastName" = ${LastName}
"email" = ${Email}
"password" = ${Password}
"phone" = ${Phone}
"userStatus" = ${UserStatus}
}
return $PSO
}
}

View File

@@ -0,0 +1,136 @@
#
# Module manifest for module 'PSPetstore'
#
# Generated by: OpenAPI Generator Team
#
# Generated on: 4/19/20
#
@{
# Script module or binary module file associated with this manifest.
RootModule = 'PSPetstore.psm1'
# Version number of this module.
ModuleVersion = '0.1.2'
# Supported PSEditions
# CompatiblePSEditions = @()
# ID used to uniquely identify this module
GUID = 'a27b908d-2a20-467f-bc32-af6f3a654ac5'
# Author of this module
Author = 'OpenAPI Generator Team'
# Company or vendor of this module
CompanyName = 'openapitools.org'
# Copyright statement for this module
Copyright = '(c) OpenAPI Generator Team. All rights reserved.'
# Description of the functionality provided by this module
Description = 'PSPetstore - the PowerShell module for OpenAPI Petstore'
# Minimum version of the PowerShell engine required by this module
PowerShellVersion = '3.0'
# Name of the PowerShell host required by this module
# PowerShellHostName = ''
# Minimum version of the PowerShell host required by this module
# PowerShellHostVersion = ''
# Minimum version of Microsoft .NET Framework required by this module. This prerequisite is valid for the PowerShell Desktop edition only.
# DotNetFrameworkVersion = ''
# Minimum version of the common language runtime (CLR) required by this module. This prerequisite is valid for the PowerShell Desktop edition only.
# CLRVersion = ''
# Processor architecture (None, X86, Amd64) required by this module
# ProcessorArchitecture = ''
# Modules that must be imported into the global environment prior to importing this module
# RequiredModules = @()
# Assemblies that must be loaded prior to importing this module
# RequiredAssemblies = @()
# Script files (.ps1) that are run in the caller's environment prior to importing this module.
# ScriptsToProcess = @()
# Type files (.ps1xml) to be loaded when importing this module
# TypesToProcess = @()
# Format files (.ps1xml) to be loaded when importing this module
# FormatsToProcess = @()
# Modules to import as nested modules of the module specified in RootModule/ModuleToProcess
# NestedModules = @()
# Functions to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no functions to export.
FunctionsToExport = 'Add-PSPet', 'Remove-Pet', 'Find-PSPetsByStatus', 'Find-PSPetsByTags',
'Get-PSPetById', 'Update-PSPet', 'Update-PSPetWithForm',
'Invoke-PSUploadFile', 'Remove-PSOrder', 'Get-PSInventory',
'Get-PSOrderById', 'Invoke-PSPlaceOrder', 'New-PSUser',
'New-PSUsersWithArrayInput', 'New-PSUsersWithListInput',
'Remove-PSUser', 'Get-PSUserByName', 'Invoke-PSLoginUser',
'Invoke-PSLogoutUser', 'Update-PSUser', 'Initialize-PSApiResponse',
'Initialize-PSCategory', 'Initialize-PSInlineObject',
'Initialize-PSInlineObject1', 'Initialize-PSOrder',
'Initialize-PSPet', 'Initialize-PSTag', 'Initialize-PSUser',
'Get-PSConfiguration', 'Set-PSConfiguration',
'Set-PSConfigurationApiKey', 'Set-PSConfigurationApiKeyPrefix',
'Set-PSConfigurationDefaultHeader', 'Get-PSHostSetting',
'Get-PSUrlFromHostSetting'
# Cmdlets to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no cmdlets to export.
CmdletsToExport = @()
# Variables to export from this module
# VariablesToExport = @()
# Aliases to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no aliases to export.
AliasesToExport = @()
# DSC resources to export from this module
# DscResourcesToExport = @()
# List of all modules packaged with this module
# ModuleList = @()
# List of all files packaged with this module
# FileList = @()
# Private data to pass to the module specified in RootModule/ModuleToProcess. This may also contain a PSData hashtable with additional module metadata used by PowerShell.
PrivateData = @{
PSData = @{
# Tags applied to this module. These help with module discovery in online galleries.
# Tags = @()
# A URL to the license for this module.
# LicenseUri = ''
# A URL to the main website for this project.
# ProjectUri = ''
# A URL to an icon representing this module.
# IconUri = ''
# ReleaseNotes of this module
# ReleaseNotes = ''
} # End of PSData hashtable
} # End of PrivateData hashtable
# HelpInfo URI of this module
# HelpInfoURI = ''
# Default prefix for commands exported from this module. Override the default prefix using Import-Module -Prefix.
# DefaultCommandPrefix = ''
}

View File

@@ -0,0 +1,29 @@
#
# OpenAPI Petstore
# This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
# Version: 1.0.0
# Generated by OpenAPI Generator: https://openapi-generator.tech
#
#region Import functions
# set $ErrorActionPreference to 'Stop' globally
$ErrorActionPreference = 'Stop'
# store the API client's configuration
$Script:Configuration = [System.Collections.HashTable]@{}
$Script:CmdletBindingParameters = @('Verbose','Debug','ErrorAction','WarningAction','InformationAction','ErrorVariable','WarningVariable','InformationVariable','OutVariable','OutBuffer','PipelineVariable')
'Api', 'Model', 'Client', 'Private' | Get-ChildItem -Path {
Join-Path $PSScriptRoot $_
} -Filter '*.ps1' | ForEach-Object {
Write-Debug "Importing file: $($_.BaseName)"
try {
. $_.FullName
} catch {
Write-Error -Message "Failed to import function $($_.Fullname): $_"
}
}
#endregion

View File

@@ -0,0 +1,21 @@
#
# OpenAPI Petstore
# This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
# Version: 1.0.0
# Generated by OpenAPI Generator: https://openapi-generator.tech
#
<#
.Synopsis
Helper function to get common parameters (Verbose, Debug, etc.)
.Example
Get-CommonParameters
#>
function Get-CommonParameters {
function tmp {
[CmdletBinding()]
Param ()
}
(Get-Command -Name tmp -CommandType Function).Parameters.Keys
}

View File

@@ -0,0 +1,44 @@
#
# OpenAPI Petstore
# This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
# Version: 1.0.0
# Generated by OpenAPI Generator: https://openapi-generator.tech
#
<#
.Synopsis
Helper function to format debug parameter output.
.Example
$PSBoundParameters | Out-DebugParameter | Write-Debug
#>
function Out-DebugParameter {
[CmdletBinding()]
Param (
[Parameter(ValueFromPipeline = $true, Mandatory = $true)]
[AllowEmptyCollection()]
$InputObject
)
Begin {
$CommonParameters = Get-CommonParameters
}
Process {
$InputObject.GetEnumerator() | Where-Object {
$CommonParameters -notcontains $_.Key
} | Format-Table -AutoSize -Property (
@{
Name = 'Parameter'
Expression = {$_.Key}
},
@{
Name = 'Value'
Expression = {$_.Value}
}
) | Out-String -Stream | ForEach-Object {
if ($_.Trim()) {
$_
}
}
}
}

View File

@@ -0,0 +1,209 @@
#
# OpenAPI Petstore
# This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
# Version: 1.0.0
# Generated by OpenAPI Generator: https://openapi-generator.tech
#
function Invoke-PSApiClient {
[OutputType('System.Collections.Hashtable')]
[CmdletBinding()]
Param(
[Parameter(Mandatory)]
[string]$Uri,
[Parameter(Mandatory)]
[AllowEmptyCollection()]
[string[]]$Accepts,
[Parameter(Mandatory)]
[AllowEmptyCollection()]
[string[]]$ContentTypes,
[Parameter(Mandatory)]
[hashtable]$HeaderParameters,
[Parameter(Mandatory)]
[hashtable]$FormParameters,
[Parameter(Mandatory)]
[hashtable]$QueryParameters,
[Parameter(Mandatory)]
[hashtable]$CookieParameters,
[Parameter(Mandatory)]
[AllowEmptyString()]
[string]$Body,
[Parameter(Mandatory)]
[string]$Method,
[Parameter(Mandatory)]
[AllowEmptyString()]
[string]$ReturnType
)
'Calling method: Invoke-PSApiClient' | Write-Debug
$PSBoundParameters | Out-DebugParameter | Write-Debug
$Configuration = Get-PSConfiguration
$RequestUri = $Configuration["BaseUrl"] + $Uri
$SkipCertificateCheck = $Configuration["SkipCertificateCheck"]
# cookie parameters
foreach ($Parameter in $CookieParameters.GetEnumerator()) {
if ($Parameter.Name -eq "cookieAuth") {
$HeaderParameters["Cookie"] = $Parameter.Value
} else {
$HeaderParameters[$Parameter.Name] = $Parameter.Value
}
}
if ($CookieParameters -and $CookieParameters.Count -gt 1) {
Write-Warning "Multipe cookie parameters found. Curently only the first one is supported/used"
}
# accept, content-type headers
$Accept = SelectHeaders -Headers $Accepts
if ($Accept) {
$HeaderParameters['Accept'] = $Accept
}
$ContentType= SelectHeaders -Headers $ContentTypes
if ($ContentType) {
$HeaderParameters['Content-Type'] = $ContentType
}
# add default headers if any
foreach ($header in $Configuration["DefaultHeaders"].GetEnumerator()) {
$HeaderParameters[$header.Name] = $header.Value
}
# constrcut URL query string
$HttpValues = [System.Web.HttpUtility]::ParseQueryString([String]::Empty)
foreach ($Parameter in $QueryParameters.GetEnumerator()) {
if ($Parameter.Value.Count -gt 1) { // array
foreach ($Value in $Parameter.Value) {
$HttpValues.Add($Parameter.Key + '[]', $Value)
}
} else {
$HttpValues.Add($Parameter.Key,$Parameter.Value)
}
}
# Build the request and load it with the query string.
$UriBuilder = [System.UriBuilder]($RequestUri)
$UriBuilder.Query = $HttpValues.ToString()
# include form parameters in the request body
if ($FormParameters -and $FormParameters.Count -gt 0) {
$RequestBody = $FormParameters
}
if ($Body) {
$RequestBody = $Body
}
# http signature authentication
if ($null -ne $Configuration['ApiKey'] -and $Configuration['ApiKey'].Count -gt 0) {
$httpSignHeaderArgument = @{
Method = $Method
UriBuilder = $UriBuilder
Body = $Body
}
$signedHeader = Get-PSHttpSignedHeader @httpSignHeaderArgument
if($null -ne $signedHeader -and $signedHeader.Count -gt 0){
foreach($item in $signedHeader.GetEnumerator()){
$HeaderParameters[$item.Name] = $item.Value
}
}
}
if ($SkipCertificateCheck -eq $true) {
$Response = Invoke-WebRequest -Uri $UriBuilder.Uri `
-Method $Method `
-Headers $HeaderParameters `
-Body $RequestBody `
-ErrorAction Stop `
-UseBasicParsing `
-SkipCertificateCheck
} else {
$Response = Invoke-WebRequest -Uri $UriBuilder.Uri `
-Method $Method `
-Headers $HeaderParameters `
-Body $RequestBody `
-ErrorAction Stop `
-UseBasicParsing
}
return @{
Response = DeserializeResponse -Response $Response -ReturnType $ReturnType -ContentTypes $Response.Headers["Content-Type"]
StatusCode = $Response.StatusCode
Headers = $Response.Headers
}
}
# Select JSON MIME if present, otherwise choose the first one if available
function SelectHeaders {
Param(
[Parameter(Mandatory)]
[AllowEmptyCollection()]
[String[]]$Headers
)
foreach ($Header in $Headers) {
if (IsJsonMIME -MIME $Header) {
return $Header
}
}
if (!($Headers) -or $Headers.Count -eq 0) {
return $null
} else {
return $Headers[0] # return the first one
}
}
function IsJsonMIME {
Param(
[Parameter(Mandatory)]
[string]$MIME
)
if ($MIME -match "(?i)^(application/json|[^;/ \t]+/[^;/ \t]+[+]json)[ \t]*(;.*)?$") {
return $true
} else {
return $false
}
}
function DeserializeResponse {
Param(
[Parameter(Mandatory)]
[AllowEmptyString()]
[string]$ReturnType,
[Parameter(Mandatory)]
[AllowEmptyString()]
[string]$Response,
[Parameter(Mandatory)]
[AllowEmptyCollection()]
[string[]]$ContentTypes
)
If ([string]::IsNullOrEmpty($ReturnType)) { # void response
return $Response
} Elseif ($ReturnType -match '\[\]$') { # array
return ConvertFrom-Json $Response
} Elseif (@("String", "Boolean", "System.DateTime") -contains $ReturnType) { # string, boolean ,datetime
return $Response
} Else { # others (e.g. model, file)
if ($ContentTypes) {
$ContentType = $null
if ($ContentTypes.Count -gt 1) {
$ContentType = SelectHeaders -Headers $ContentTypes
} else {
$ContentType = $ContentTypes[0]
}
if (IsJsonMIME -MIME $ContentType) { # JSON
return ConvertFrom-Json $Response
} else { # XML, file, etc
return $Response
}
} else { # no content type in response header, returning raw response
return $Response
}
}
}

View File

@@ -0,0 +1,19 @@
PSTOPIC
about_PSPetstore
SHORT DESCRIPTION
PSPetstore - the PowerShell module for the OpenAPI Petstore
LONG DESCRIPTION
This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
This PowerShell module is automatically generated by the [OpenAPI Generator](https://openapi-generator.tech) project:
- API version: 1.0.0
- SDK version: 0.1.2
- Build package: org.openapitools.codegen.languages.PowerShellClientCodegen
Frameworks supported:
* PowerShell 3.0+
* .NET 4.0 or later