forked from loafle/openapi-generator-original
Adds configuration option to skip certificate check. Fixes a typo. Fixes an issue which was restricting from cookie to get consumed (#5657)
This commit is contained in:
parent
5549c1dd2d
commit
4de97a47e3
@ -34,14 +34,17 @@ function Invoke-{{{apiNamePrefix}}}ApiClient {
|
||||
|
||||
$Configuration = Get-{{{apiNamePrefix}}}Configuration
|
||||
$RequestUri = $Configuration["BaseUrl"] + $Uri
|
||||
$SkipCertificateCheck = $Configuration["SkipCertificateCheck"]
|
||||
|
||||
# cookie parameters
|
||||
foreach ($Parameter in $CookieParameters) {
|
||||
if ($CookieParameters[$Parameter]) {
|
||||
$HeaderParameters["Cookie"] = $CookieParameters[$Parameter]
|
||||
foreach ($Parameter in $CookieParameters.GetEnumerator()) {
|
||||
if ($Parameter.Name -eq "cookieAuth") {
|
||||
$HeaderParameters["Cookie"] = $Parameter.Value
|
||||
} else {
|
||||
$HeaderParameters[$Parameter.Name] = $Parameter.Value
|
||||
}
|
||||
}
|
||||
if ($CookieParametters -and $CookieParameters.Count -gt 1) {
|
||||
if ($CookieParameters -and $CookieParameters.Count -gt 1) {
|
||||
Write-Warning "Multipe cookie parameters found. Curently only the first one is supported/used"
|
||||
}
|
||||
|
||||
@ -80,11 +83,21 @@ function Invoke-{{{apiNamePrefix}}}ApiClient {
|
||||
$RequestBody = $Body
|
||||
}
|
||||
|
||||
$Response = Invoke-WebRequest -Uri $UriBuilder.Uri `
|
||||
if ($SkipCertificateCheck -eq $true) {
|
||||
$Response = Invoke-WebRequest -Uri $UriBuilder.Uri `
|
||||
-Method $Method `
|
||||
-Headers $HeaderParameters `
|
||||
-Body $RequestBody `
|
||||
-ErrorAction Stop `
|
||||
-SkipCertificateCheck
|
||||
|
||||
} else {
|
||||
$Response = Invoke-WebRequest -Uri $UriBuilder.Uri `
|
||||
-Method $Method `
|
||||
-Headers $HeaderParameters `
|
||||
-Body $RequestBody `
|
||||
-ErrorAction Stop
|
||||
}
|
||||
|
||||
return @{
|
||||
Response = DeserializeResponse -Response $Response -ReturnType $ReturnType
|
||||
|
@ -28,6 +28,10 @@ function Get-{{apiNamePrefix}}Configuration {
|
||||
$Configuration["ApiKeyPrefix"] = @{}
|
||||
}
|
||||
|
||||
if (!$Configuration.containsKey("SkipCertificateCheck")) {
|
||||
$Configuration["SkipCertificateCheck"] = $false
|
||||
}
|
||||
|
||||
Return $Configuration
|
||||
|
||||
}
|
||||
@ -48,6 +52,7 @@ function Set-{{{apiNamePrefix}}}Configuration {
|
||||
[AllowEmptyString()]
|
||||
[string]$AccessToken,
|
||||
[switch]$PassThru,
|
||||
[bool]$SkipCertificateCheck,
|
||||
[switch]$Force
|
||||
)
|
||||
|
||||
@ -80,6 +85,10 @@ function Set-{{{apiNamePrefix}}}Configuration {
|
||||
If ($AccessToken) {
|
||||
$Script:Configuration['AccessToken'] = $AccessToken
|
||||
}
|
||||
|
||||
If ($SkipCertificateCheck) {
|
||||
$Script:Configuration['SkipCertificateCheck'] = $SkipCertificateCheck
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user