Skip to content

Commit

Permalink
[PS][PowerShell] fix passthru, use switch instead of bool (#5768)
Browse files Browse the repository at this point in the history
* fix passthru, use switch

* remove line
  • Loading branch information
wing328 authored Mar 31, 2020
1 parent 7e22b4b commit 3316f17
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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 {
Expand Down Expand Up @@ -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
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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 {
Expand Down Expand Up @@ -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
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#
# Generated by: OpenAPI Generator Team
#
# Generated on: 3/30/20
# Generated on: 3/31/20
#

@{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}
}

0 comments on commit 3316f17

Please sign in to comment.