[PS][PowerShell] fix passthru, use switch instead of bool (#5768)

* fix passthru, use switch

* remove line
This commit is contained in:
William Cheng 2020-03-31 19:10:27 +08:00 committed by GitHub
parent 7e22b4b8cf
commit 3316f17ed5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 36 additions and 13 deletions

View File

@ -89,6 +89,9 @@ 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
@ -108,10 +111,9 @@ function Set-{{{apiNamePrefix}}}Configuration {
[string]$Cookie,
[AllowEmptyString()]
[string]$AccessToken,
[switch]$PassThru,
[bool]$SkipCertificateCheck,
[switch]$SkipCertificateCheck,
[hashtable]$DefaultHeaders,
[switch]$Force
[switch]$PassThru
)
Process {
@ -144,13 +146,19 @@ function Set-{{{apiNamePrefix}}}Configuration {
$Script:Configuration['AccessToken'] = $AccessToken
}
If ($SkipCertificateCheck) {
$Script:Configuration['SkipCertificateCheck'] = $SkipCertificateCheck
If ($SkipCertificateCheck.IsPresent) {
$Script:Configuration['SkipCertificateCheck'] = $true
} else {
$Script:Configuration['SkipCertificateCheck'] = $false
}
If ($DefaultHeaders) {
$Script:Configuration['DefaultHeaders'] = $DefaultHeaders
}
If ($PassThru.IsPresent) {
$Script:Configuration
}
}
}

View File

@ -95,6 +95,9 @@ 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
@ -114,10 +117,9 @@ function Set-PSConfiguration {
[string]$Cookie,
[AllowEmptyString()]
[string]$AccessToken,
[switch]$PassThru,
[bool]$SkipCertificateCheck,
[switch]$SkipCertificateCheck,
[hashtable]$DefaultHeaders,
[switch]$Force
[switch]$PassThru
)
Process {
@ -150,13 +152,19 @@ function Set-PSConfiguration {
$Script:Configuration['AccessToken'] = $AccessToken
}
If ($SkipCertificateCheck) {
$Script:Configuration['SkipCertificateCheck'] = $SkipCertificateCheck
If ($SkipCertificateCheck.IsPresent) {
$Script:Configuration['SkipCertificateCheck'] = $true
} else {
$Script:Configuration['SkipCertificateCheck'] = $false
}
If ($DefaultHeaders) {
$Script:Configuration['DefaultHeaders'] = $DefaultHeaders
}
If ($PassThru.IsPresent) {
$Script:Configuration
}
}
}

View File

@ -3,7 +3,7 @@
#
# Generated by: OpenAPI Generator Team
#
# Generated on: 3/30/20
# Generated on: 3/31/20
#
@{

View File

@ -94,5 +94,12 @@ Describe -tag 'PSOpenAPITools' -name 'Integration Tests' {
$Configuration["DefaultHeaders"]["TestKey"] | Should Be "TestValue"
}
It "Configuration tests" {
$Conf = Get-PSConfiguration
$Conf["SkipCertificateCheck"] | Should Be $false
$Conf = Set-PSConfiguration -PassThru -SkipCertificateCheck
$Conf["SkipCertificateCheck"] | Should Be $true
}
}
}