OpenAPI: Fix security display issues

This commit is contained in:
Fuma Nama
2025-03-28 21:22:01 +08:00
parent d0edf3554d
commit c37b12a066
2 changed files with 12 additions and 2 deletions
+5
View File
@@ -0,0 +1,5 @@
---
'fumadocs-openapi': patch
---
Fix security display issues
@@ -56,7 +56,6 @@ export function Operation({
headingLevel?: number;
}): ReactElement {
const body = method.requestBody;
const security = method.security ?? ctx.schema.document.security;
let headNode: ReactNode = null;
let bodyNode: ReactNode = null;
let responseNode: ReactNode = null;
@@ -191,6 +190,12 @@ export function Operation({
);
}
const security = (
method.security ??
ctx.schema.document.security ??
[]
).filter((v) => Object.keys(v).length > 0);
const info = (
<ctx.renderer.APIInfo head={headNode} method={method.method} route={path}>
{type === 'operation' ? (
@@ -205,7 +210,7 @@ export function Operation({
<ctx.renderer.APIPlayground path={path} method={method} ctx={ctx} />
)
) : null}
{security && Object.keys(security).length > 0 ? (
{security.length > 0 ? (
<>
{heading(headingLevel, 'Authorization', ctx)}
<AuthSection requirements={security} ctx={ctx} />