[PowerShell] Support ApiKeyPrefix (#19133)

* Support for ApiKeyPrefix

* Additional files after build
This commit is contained in:
condorcorde 2024-07-11 08:38:16 +02:00 committed by GitHub
parent 9948ed2cfa
commit 2940d3219c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 25 additions and 5 deletions

View File

@ -177,15 +177,20 @@ function {{{vendorExtensions.x-powershell-method-name}}} {
{{/bodyParam}}
{{#authMethods}}
{{#isApiKey}}
if ($Configuration["ApiKeyPrefix"] -and $Configuration["ApiKeyPrefix"]["{{{keyParamName}}}"]) {
$apiKeyPrefix = $Configuration["ApiKeyPrefix"]["{{{keyParamName}}}"]
} else {
$apiKeyPrefix = ""
}
{{#isKeyInHeader}}
if ($Configuration["ApiKey"] -and $Configuration["ApiKey"]["{{{keyParamName}}}"]) {
$LocalVarHeaderParameters['{{{keyParamName}}}'] = $Configuration["ApiKey"]["{{{keyParamName}}}"]
$LocalVarHeaderParameters['{{{keyParamName}}}'] = $apiKeyPrefix + $Configuration["ApiKey"]["{{{keyParamName}}}"]
Write-Verbose ("Using API key '{{{keyParamName}}}' in the header for authentication in {0}" -f $MyInvocation.MyCommand)
}
{{/isKeyInHeader}}
{{#isKeyInQuery}}
if ($Configuration["ApiKey"] -and $Configuration["ApiKey"]["{{{keyParamName}}}"]) {
$LocalVarQueryParameters['{{{keyParamName}}}'] = $Configuration["ApiKey"]["{{{keyParamName}}}"]
$LocalVarQueryParameters['{{{keyParamName}}}'] = $apiKeyPrefix + $Configuration["ApiKey"]["{{{keyParamName}}}"]
Write-Verbose ("Using API key `{{{keyParamName}}}` in the URL query for authentication in {0}" -f $MyInvocation.MyCommand)
}
{{/isKeyInQuery}}

View File

@ -63,8 +63,13 @@ function Test-PSClassname {
$LocalVarBodyParameter = $Client | ConvertTo-Json -Depth 100
if ($Configuration["ApiKeyPrefix"] -and $Configuration["ApiKeyPrefix"]["api_key_query_name"]) {
$apiKeyPrefix = $Configuration["ApiKeyPrefix"]["api_key_query_name"]
} else {
$apiKeyPrefix = ""
}
if ($Configuration["ApiKey"] -and $Configuration["ApiKey"]["api_key_query_name"]) {
$LocalVarQueryParameters['api_key_query_name'] = $Configuration["ApiKey"]["api_key_query_name"]
$LocalVarQueryParameters['api_key_query_name'] = $apiKeyPrefix + $Configuration["ApiKey"]["api_key_query_name"]
Write-Verbose ("Using API key `api_key_query_name` in the URL query for authentication in {0}" -f $MyInvocation.MyCommand)
}

View File

@ -405,8 +405,13 @@ function Get-PSPetById {
}
$LocalVarUri = $LocalVarUri.replace('{petId}', [System.Web.HTTPUtility]::UrlEncode($PetId))
if ($Configuration["ApiKeyPrefix"] -and $Configuration["ApiKeyPrefix"]["api_key_name"]) {
$apiKeyPrefix = $Configuration["ApiKeyPrefix"]["api_key_name"]
} else {
$apiKeyPrefix = ""
}
if ($Configuration["ApiKey"] -and $Configuration["ApiKey"]["api_key_name"]) {
$LocalVarHeaderParameters['api_key_name'] = $Configuration["ApiKey"]["api_key_name"]
$LocalVarHeaderParameters['api_key_name'] = $apiKeyPrefix + $Configuration["ApiKey"]["api_key_name"]
Write-Verbose ("Using API key 'api_key_name' in the header for authentication in {0}" -f $MyInvocation.MyCommand)
}

View File

@ -118,8 +118,13 @@ function Get-PSInventory {
$LocalVarUri = '/store/inventory'
if ($Configuration["ApiKeyPrefix"] -and $Configuration["ApiKeyPrefix"]["api_key_name"]) {
$apiKeyPrefix = $Configuration["ApiKeyPrefix"]["api_key_name"]
} else {
$apiKeyPrefix = ""
}
if ($Configuration["ApiKey"] -and $Configuration["ApiKey"]["api_key_name"]) {
$LocalVarHeaderParameters['api_key_name'] = $Configuration["ApiKey"]["api_key_name"]
$LocalVarHeaderParameters['api_key_name'] = $apiKeyPrefix + $Configuration["ApiKey"]["api_key_name"]
Write-Verbose ("Using API key 'api_key_name' in the header for authentication in {0}" -f $MyInvocation.MyCommand)
}