UNPKG

fumadocs-openapi

Version:

Generate MDX docs for your OpenAPI spec

71 lines (70 loc) 2.14 kB
import { OperationOutput, OutputGroup, PagesBuilder, PagesBuilderConfig, TagOutput, WebhookOutput } from "./builder.js"; import { ProcessedDocument } from "../process-document.js"; //#region src/utils/pages/preset-auto.d.ts interface OperationConfig extends BaseConfig { /** * Generate a page for each API endpoint/operation (default). */ per?: 'operation'; /** * Group output using folders (Only works on `operation` mode) * - tag: `{tag}/{file}` * - route: `{endpoint}/{method}` (it will ignore the `name` option) * - none: `{file}` (default) * - a function that aligns group name (folder path) to each entry * * @defaultValue 'none' */ groupBy?: 'tag' | 'route' | 'none' | ((entry: OperationOutput | WebhookOutput) => string); /** * Specify name for output file */ name?: NameFn<OperationOutput | WebhookOutput> | NameFnOptions; } interface TagConfig extends BaseConfig { /** * Generate a page for each tag. */ per: 'tag'; /** * Specify name for output file */ name?: NameFn<TagOutput> | NameFnOptions; } interface SchemaConfig extends BaseConfig { /** * Generate a page for each schema file. */ per: 'file'; /** * Specify name for output file */ name?: NameFn<OutputGroup> | NameFnOptions; } type SchemaToPagesOptions = SchemaConfig | TagConfig | OperationConfig | ({ per: 'custom'; } & PagesBuilderConfig); type NameFn<Entry> = (this: PagesBuilder, output: Entry, document: ProcessedDocument['dereferenced']) => string; interface NameFnOptions { /** * The version of algorithm used to generate file paths. * * v1: Fumadocs OpenAPI v8 * v2: Fumadocs OpenAPI v9 * * @defaultValue v2 */ algorithm?: 'v2' | 'v1'; } interface BaseConfig { /** * Custom function to convert names into file names. * * By default, it only escapes whitespaces and upper case (English) characters */ slugify?: (name: string) => string; } declare function createAutoPreset(options: SchemaToPagesOptions): PagesBuilderConfig; //#endregion export { SchemaToPagesOptions, createAutoPreset }; //# sourceMappingURL=preset-auto.d.ts.map