OpenAPI: Support adding description to generated document body

This commit is contained in:
fuma-nama
2024-08-25 00:40:53 +08:00
parent 029a1565a6
commit eb922e1b68
3 changed files with 15 additions and 1 deletions
+5
View File
@@ -0,0 +1,5 @@
---
'fumadocs-openapi': patch
---
Support adding `description` to generated document body
+7
View File
@@ -51,6 +51,13 @@ export interface GenerateOptions {
context: DocumentContext,
) => Record<string, unknown>;
/**
* Add description to document body
*
* @defaultValue false
*/
includeDescription?: boolean;
cwd?: string;
}
@@ -22,7 +22,7 @@ export function generateDocument(
context: DocumentContext;
},
): string {
const { frontmatter } = options;
const { frontmatter, includeDescription = false } = options;
const out: string[] = [];
const extend = frontmatter?.(
options.title,
@@ -64,6 +64,8 @@ export function generateDocument(
out.push(imports);
}
if (options.description && includeDescription) out.push(options.description);
out.push(pageContent(options.page));
return out.join('\n\n');