diff --git a/.changeset/calm-shirts-tie.md b/.changeset/calm-shirts-tie.md new file mode 100644 index 0000000000..2ecafaa2e6 --- /dev/null +++ b/.changeset/calm-shirts-tie.md @@ -0,0 +1,5 @@ +--- +'@gitbook/react-openapi': patch +--- + +Re-arrange OpenAPI Scopes for OAuth2 diff --git a/packages/react-openapi/src/OpenAPIRequiredScopes.tsx b/packages/react-openapi/src/OpenAPIRequiredScopes.tsx index 78436f2081..6bef0def09 100644 --- a/packages/react-openapi/src/OpenAPIRequiredScopes.tsx +++ b/packages/react-openapi/src/OpenAPIRequiredScopes.tsx @@ -25,12 +25,6 @@ export function OpenAPIRequiredScopes(props: { } const scopes = selectedSecurity.schemes.flatMap((scheme) => { - if (scheme.type === 'oauth2') { - return Object.entries(scheme.flows ?? {}).flatMap(([_, flow]) => - Object.entries(flow.scopes ?? {}) - ); - } - return scheme.scopes ?? []; }); @@ -66,16 +60,20 @@ export function OpenAPIRequiredScopes(props: { ); } -function OpenAPISchemaScopes(props: { +export function OpenAPISchemaScopes(props: { scopes: OpenAPISecurityScope[]; context: OpenAPIClientContext; + isOAuth2?: boolean; }) { - const { scopes, context } = props; + const { scopes, context, isOAuth2 } = props; return (