Skip to content

Commit 8b7f79d

Browse files
committed
api-key-value was not getting applied on request header
1 parent b74e19b commit 8b7f79d

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

src/templates/security-scheme-template.js

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,21 +5,21 @@ import marked from 'marked';
55
const codeVerifier = '731DB1C3F7EA533B85E29492D26AA-1234567890-1234567890';
66
const codeChallenge = '4FatVDBJKPAo4JgLLaaQFMUcQPn5CrPRvLlaob9PTYc'; // Base64 encoded SHA-256
77

8-
export function applyApiKey(securitySchemeId, username = '', password = '', apikeyVal = '') {
8+
export function applyApiKey(securitySchemeId, username = '', password = '', providedApikeyVal = '') {
99
const securityObj = this.resolvedSpec.securitySchemes?.find((v) => (v.securitySchemeId === securitySchemeId));
1010
if (!securityObj) {
1111
return false;
1212
}
13-
let apiKeyValue = '';
14-
if (securityObj.type && securityObj.scheme && securityObj.type === 'http' && securityObj.scheme.toLowerCase() === 'basic') {
13+
let finalApiKeyValue = '';
14+
if (securityObj.scheme?.toLowerCase() === 'basic') {
1515
if (username) {
16-
apiKeyValue = `Basic ${btoa(`${username}:${password}`)}`;
16+
finalApiKeyValue = `Basic ${btoa(`${username}:${password}`)}`;
1717
}
18-
} else if (apikeyVal) {
19-
apiKeyValue = `${securityObj.scheme?.toLowerCase() === 'bearer' ? 'Bearer' : ''} ${apiKeyValue}`;
18+
} else if (providedApikeyVal) {
19+
finalApiKeyValue = `${securityObj.scheme?.toLowerCase() === 'bearer' ? 'Bearer' : ''} ${providedApikeyVal}`;
2020
}
21-
if (apiKeyValue) {
22-
securityObj.finalKeyValue = apiKeyValue;
21+
if (finalApiKeyValue) {
22+
securityObj.finalKeyValue = finalApiKeyValue;
2323
this.requestUpdate();
2424
return true;
2525
}

0 commit comments

Comments
 (0)