redoc/src/components/SecurityRequirement/RequiredScopesRow.tsx
adamsosterics 04493ba933
feat: show sets of required scopes correctly
It is possible to define alternative required scopes for an operation
and in the security header of the operation it is rendered correctly.
However, in the "Required scopes" part it looks like that all these scopes are required.
With these changes, the "Required scopes" part shows the required scopes per set.

See: https://github.com/OAI/OpenAPI-Specification/discussions/3001#discussioncomment-3456275
2025-09-23 11:30:22 +02:00

26 lines
667 B
TypeScript

import * as React from 'react';
export const RequiredScopesRow = ({ scopeSets }: { scopeSets: string[][] }): JSX.Element | null => {
if (!scopeSets.length) return null;
return (
<div>
<b>Required scopes: </b>
{scopeSets.map((scopeSet, ssIdx) => {
return (
<React.Fragment key={ssIdx}>
{scopeSet.map((scope, idx) => {
return (
<React.Fragment key={idx}>
<code>{scope}</code>{' '}
</React.Fragment>
);
})}
{ssIdx + 1 < scopeSets.length && ' or '}
</React.Fragment>
);
})}
</div>
);
};