Skip to content

Commit ad84ffe

Browse files
committed
added casses for MD-SESSION-TOKEN & MD-API-TOKEN
1 parent a0cf0ce commit ad84ffe

1 file changed

Lines changed: 23 additions & 4 deletions

File tree

packages/docusaurus-theme-openapi-docs/src/theme/ApiExplorer/buildPostmanRequest.ts

Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -282,20 +282,39 @@ function buildPostmanRequest(
282282
// Basic Auth
283283
if (a.type === "http" && a.scheme === "basic") {
284284
const { username, password } = auth.data[a.key];
285+
285286
if (username === undefined || password === undefined) {
286-
otherHeaders.push({
287-
key: "Authorization",
288-
value: "Basic BASE_64_ENCODING_OF <client_id:api_key>",
289-
});
287+
// Dynamic scheme-based header fallback
288+
switch (a.key) {
289+
case "MD-SESSION-TOKEN":
290+
otherHeaders.push({
291+
key: "MD-SESSION-TOKEN",
292+
value: "<SESSION_TOKEN_VALUE>",
293+
});
294+
break;
295+
case "MD-API-TOKEN":
296+
otherHeaders.push({
297+
key: "MD-API-TOKEN",
298+
value: "<API_KEY_VALUE>",
299+
});
300+
break;
301+
default:
302+
otherHeaders.push({
303+
key: "Authorization",
304+
value: "Basic BASE_64_ENCODING_OF{client_id:api_key}",
305+
});
306+
}
290307
continue;
291308
}
309+
292310
otherHeaders.push({
293311
key: "Authorization",
294312
value: `Basic ${window.btoa(`${username}:${password}`)}`,
295313
});
296314
continue;
297315
}
298316

317+
299318
// API Key
300319
if (a.type === "apiKey" && a.in === "header") {
301320
const { apiKey } = auth.data[a.key];

0 commit comments

Comments
 (0)