Skip to content

Commit 3e40b4d

Browse files
authored
Fix OpenAPI basic auth placeholder (#3816)
1 parent 854e612 commit 3e40b4d

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

.changeset/ready-ducks-burn.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@gitbook/react-openapi': patch
3+
---
4+
5+
Fix OpenAPI basic auth placeholder

packages/react-openapi/src/OpenAPICodeSample.tsx

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -315,11 +315,12 @@ function getSecurityHeaders(args: {
315315
switch (security.type) {
316316
case 'http': {
317317
let scheme = security.scheme;
318+
const defaultPlaceholderValue = scheme?.toLowerCase()?.includes('basic')
319+
? 'username:password'
320+
: 'YOUR_SECRET_TOKEN';
318321
const format = resolvePrefillCodePlaceholderFromSecurityScheme({
319322
security: security,
320-
defaultPlaceholderValue: scheme?.includes('basic')
321-
? 'username:password'
322-
: 'YOUR_SECRET_TOKEN',
323+
defaultPlaceholderValue,
323324
});
324325

325326
if (scheme?.includes('bearer')) {

0 commit comments

Comments
 (0)