1- import type { OpenAPIV3_1 } from '@gitbook/openapi-parser' ;
21import { InteractiveSection } from './InteractiveSection' ;
32import { Markdown } from './Markdown' ;
43import { OpenAPISchemaName } from './OpenAPISchemaName' ;
5- import type { OpenAPIClientContext , OpenAPIOperationData } from './types' ;
4+ import type {
5+ OpenAPIClientContext ,
6+ OpenAPIOperationData ,
7+ OpenAPISecurityWithRequired ,
8+ } from './types' ;
69import { resolveDescription } from './utils' ;
710
811/**
@@ -50,26 +53,36 @@ export function OpenAPISecurities(props: {
5053 ) ;
5154}
5255
53- function getLabelForType ( security : OpenAPIV3_1 . SecuritySchemeObject ) {
56+ function getLabelForType ( security : OpenAPISecurityWithRequired ) {
5457 switch ( security . type ) {
5558 case 'apiKey' :
5659 return (
5760 < OpenAPISchemaName
5861 propertyName = { security . name ?? 'apiKey' }
5962 type = "string"
60- required
63+ required = { security . required }
6164 />
6265 ) ;
6366 case 'http' :
6467 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+ ) ;
6675 }
6776
6877 if ( security . scheme === 'bearer' ) {
6978 const description = resolveDescription ( security ) ;
7079 return (
7180 < >
72- < OpenAPISchemaName propertyName = "Authorization" type = "string" required />
81+ < OpenAPISchemaName
82+ propertyName = "Authorization"
83+ type = "string"
84+ required = { security . required }
85+ />
7386 { /** Show a default description if none is provided */ }
7487 { ! description ? (
7588 < Markdown
@@ -81,11 +94,11 @@ function getLabelForType(security: OpenAPIV3_1.SecuritySchemeObject) {
8194 ) ;
8295 }
8396
84- return < OpenAPISchemaName propertyName = "HTTP" required /> ;
97+ return < OpenAPISchemaName propertyName = "HTTP" required = { security . required } /> ;
8598 case 'oauth2' :
86- return < OpenAPISchemaName propertyName = "OAuth2" required /> ;
99+ return < OpenAPISchemaName propertyName = "OAuth2" required = { security . required } /> ;
87100 case 'openIdConnect' :
88- return < OpenAPISchemaName propertyName = "OpenID Connect" required /> ;
101+ return < OpenAPISchemaName propertyName = "OpenID Connect" required = { security . required } /> ;
89102 default :
90103 // @ts -ignore
91104 return security . type ;
0 commit comments