@@ -3,7 +3,7 @@ import { Fragment } from 'react';
33import { InteractiveSection } from './InteractiveSection' ;
44import { Markdown } from './Markdown' ;
55import { OpenAPICopyButton } from './OpenAPICopyButton' ;
6- import { OpenAPIRequiredScopes } from './OpenAPIRequiredScopes' ;
6+ import { OpenAPIRequiredScopes , OpenAPISchemaScopes } from './OpenAPIRequiredScopes' ;
77import { OpenAPISchemaName } from './OpenAPISchemaName' ;
88import type { OpenAPIClientContext } from './context' ;
99import { t } from './translate' ;
@@ -43,7 +43,11 @@ export function OpenAPISecurities(props: {
4343 body : (
4444 < div className = "openapi-schema" >
4545 { schemes . map ( ( security , index ) => {
46- const description = resolveDescription ( security ) ;
46+ // OAuth2 description is already rendered in OpenAPISchemaOAuth2Item
47+ const description =
48+ security . type !== 'oauth2'
49+ ? resolveDescription ( security )
50+ : undefined ;
4751 return (
4852 < div
4953 key = { `${ key } -${ index } ` }
@@ -172,6 +176,10 @@ function OpenAPISchemaOAuth2Item(props: {
172176 return null ;
173177 }
174178
179+ const scopes = ! security . scopes ?. length && flow . scopes ? Object . entries ( flow . scopes ) : [ ] ;
180+
181+ const description = resolveDescription ( security ) ;
182+
175183 return (
176184 < div >
177185 < OpenAPISchemaName
@@ -181,7 +189,9 @@ function OpenAPISchemaOAuth2Item(props: {
181189 required = { security . required }
182190 />
183191 < div className = "openapi-securities-oauth-content openapi-markdown" >
184- { security . description ? < Markdown source = { security . description } /> : null }
192+ { description ? (
193+ < Markdown source = { description } className = "openapi-securities-description" />
194+ ) : null }
185195 { 'authorizationUrl' in flow && flow . authorizationUrl ? (
186196 < span >
187197 Authorization URL:{ ' ' }
@@ -221,6 +231,9 @@ function OpenAPISchemaOAuth2Item(props: {
221231 </ OpenAPICopyButton >
222232 </ span >
223233 ) : null }
234+ { scopes . length ? (
235+ < OpenAPISchemaScopes scopes = { scopes } context = { context } isOAuth2 />
236+ ) : null }
224237 </ div >
225238 </ div >
226239 ) ;
0 commit comments