1
- import type { OpenAPIV3_1 } from '@gitbook/openapi-parser' ;
2
1
import { InteractiveSection } from './InteractiveSection' ;
3
2
import { Markdown } from './Markdown' ;
4
3
import { OpenAPISchemaName } from './OpenAPISchemaName' ;
5
- import type { OpenAPIClientContext , OpenAPIOperationData } from './types' ;
4
+ import type {
5
+ OpenAPIClientContext ,
6
+ OpenAPIOperationData ,
7
+ OpenAPISecurityWithRequired ,
8
+ } from './types' ;
6
9
import { resolveDescription } from './utils' ;
7
10
8
11
/**
@@ -50,26 +53,36 @@ export function OpenAPISecurities(props: {
50
53
) ;
51
54
}
52
55
53
- function getLabelForType ( security : OpenAPIV3_1 . SecuritySchemeObject ) {
56
+ function getLabelForType ( security : OpenAPISecurityWithRequired ) {
54
57
switch ( security . type ) {
55
58
case 'apiKey' :
56
59
return (
57
60
< OpenAPISchemaName
58
61
propertyName = { security . name ?? 'apiKey' }
59
62
type = "string"
60
- required
63
+ required = { security . required }
61
64
/>
62
65
) ;
63
66
case 'http' :
64
67
if ( security . scheme === 'basic' ) {
65
- return < OpenAPISchemaName propertyName = "Authorization" type = "string" required /> ;
68
+ return (
69
+ < OpenAPISchemaName
70
+ propertyName = "Authorization"
71
+ type = "string"
72
+ required = { security . required }
73
+ />
74
+ ) ;
66
75
}
67
76
68
77
if ( security . scheme === 'bearer' ) {
69
78
const description = resolveDescription ( security ) ;
70
79
return (
71
80
< >
72
- < OpenAPISchemaName propertyName = "Authorization" type = "string" required />
81
+ < OpenAPISchemaName
82
+ propertyName = "Authorization"
83
+ type = "string"
84
+ required = { security . required }
85
+ />
73
86
{ /** Show a default description if none is provided */ }
74
87
{ ! description ? (
75
88
< Markdown
@@ -81,11 +94,11 @@ function getLabelForType(security: OpenAPIV3_1.SecuritySchemeObject) {
81
94
) ;
82
95
}
83
96
84
- return < OpenAPISchemaName propertyName = "HTTP" required /> ;
97
+ return < OpenAPISchemaName propertyName = "HTTP" required = { security . required } /> ;
85
98
case 'oauth2' :
86
- return < OpenAPISchemaName propertyName = "OAuth2" required /> ;
99
+ return < OpenAPISchemaName propertyName = "OAuth2" required = { security . required } /> ;
87
100
case 'openIdConnect' :
88
- return < OpenAPISchemaName propertyName = "OpenID Connect" required /> ;
101
+ return < OpenAPISchemaName propertyName = "OpenID Connect" required = { security . required } /> ;
89
102
default :
90
103
// @ts -ignore
91
104
return security . type ;
0 commit comments