'use client'; import { OpenAPICopyButton } from './OpenAPICopyButton'; import { OpenAPIDisclosureGroup } from './OpenAPIDisclosureGroup'; import { useSelectState } from './OpenAPISelect'; import type { OpenAPIClientContext } from './context'; import { t } from './translate'; import type { OpenAPISecurityScope } from './types'; import type { OperationSecurityInfo } from './utils'; /** * Present securities authorization that can be used for this operation. */ export function OpenAPIRequiredScopes(props: { securities: OperationSecurityInfo[]; context: OpenAPIClientContext; stateKey: string; }) { const { securities, stateKey, context } = props; const { key: selectedKey } = useSelectState(stateKey, securities[0]?.key); const selectedSecurity = securities.find((security) => security.key === selectedKey); if (!selectedSecurity) { return null; } const scopes = selectedSecurity.schemes.flatMap((scheme) => { return scheme.scopes ?? []; }); if (!scopes.length) { return null; } return ( {context.icons.lock} {t(context.translation, 'required_scopes')} ), tabs: [ { key: 'scopes', label: '', body: , }, ], }, ]} /> ); } export function OpenAPISchemaScopes(props: { scopes: OpenAPISecurityScope[]; context: OpenAPIClientContext; }) { const { scopes, context } = props; return (
{t(context.translation, 'required_scopes_description')}
    {scopes.map((scope) => ( ))}
); } /** * Display a scope item. Either a key-value pair or a single string. */ function OpenAPIScopeItem(props: { scope: OpenAPISecurityScope; context: OpenAPIClientContext; }) { const { scope, context } = props; return (
  • {scope[1] ? : {scope[1]} : null}
  • ); } /** * Displays the scope name within a copyable button. */ function OpenAPIScopeItemKey(props: { name: string; context: OpenAPIClientContext; }) { const { name, context } = props; return ( {name} ); }