mirror of
https://github.com/GitbookIO/gitbook.git
synced 2026-09-21 10:03:31 +00:00
Include apiKey example in CodeSample security headers (#2804)
This commit is contained in:
@@ -0,0 +1,5 @@
|
|||||||
|
---
|
||||||
|
'@gitbook/react-openapi': patch
|
||||||
|
---
|
||||||
|
|
||||||
|
Support apiKey in CodeSample security headers
|
||||||
@@ -153,6 +153,28 @@ function getSecurityHeaders(securities: OpenAPIOperationData['securities']): {
|
|||||||
Authorization: scheme + ' ' + (security[1].bearerFormat ?? '<token>'),
|
Authorization: scheme + ' ' + (security[1].bearerFormat ?? '<token>'),
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
case 'apiKey': {
|
||||||
|
if (security[1].in !== 'header') return {};
|
||||||
|
|
||||||
|
const name = security[1].name ?? 'Authorization';
|
||||||
|
let scheme = security[0];
|
||||||
|
|
||||||
|
switch (scheme) {
|
||||||
|
case 'bearerAuth':
|
||||||
|
scheme = 'Bearer';
|
||||||
|
break;
|
||||||
|
case 'token':
|
||||||
|
scheme = 'Token';
|
||||||
|
break;
|
||||||
|
case 'basic':
|
||||||
|
scheme = 'Basic';
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
return {
|
||||||
|
[name]: scheme + ' ' + '<apiKey>',
|
||||||
|
};
|
||||||
|
}
|
||||||
default: {
|
default: {
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user