import { MediaAdapter } from "../requests/media/adapter.js"; import { CodeUsageGeneratorRegistry, InlineCodeUsageGenerator } from "../requests/generators/index.js"; import { ExampleRequestItem } from "../utils/get-example-requests.js"; import { RequestTabsRenderOptions } from "./operation/request-tabs.js"; import { ResponseTabsRenderOptions } from "./operation/response-tabs.js"; import { ParsedSchema } from "../utils/schema.js"; import { PlaygroundClientOptions } from "../playground/client.js"; import { GeneratedPageProps, OperationItem, WebhookItem } from "../utils/pages/builder.js"; import { Awaitable, Document, HttpMethods, OperationObject, PathItemObject, RenderContext } from "../types.js"; import { ComponentProps, FC, HTMLAttributes, ReactNode } from "react"; import { ShikiFactory } from "fumadocs-core/highlight/shiki"; import { BundledTheme, CodeOptionsThemes, CodeToHastOptionsCommon } from "shiki"; //#region src/ui/index.d.ts interface GenerateTypeScriptDefinitionsContext { name: string; readOnly: boolean; writeOnly: boolean; ctx: RenderContext; } interface APIPlaygroundProps { path: string; method: HttpMethods; operation: OperationObject; pathItem: PathItemObject; ctx: RenderContext; } interface CreateOpenAPIPageOptions { /** * Generate TypeScript definitions from JSON schema. * * Pass `false` to disable it. */ generateTypeScriptDefinitions?: ((schema: ParsedSchema, ctx: GenerateTypeScriptDefinitionsContext) => Awaitable) | false; /** * Generate example code usage for all endpoints. */ codeUsages?: CodeUsageGeneratorRegistry; /** * Generate example code usage for each endpoint. */ generateCodeSamples?: (options: { operation: OperationObject; method: HttpMethods; pathItem: PathItemObject; }) => InlineCodeUsageGenerator[]; shiki?: ShikiFactory; shikiOptions?: Omit & CodeOptionsThemes; /** * Show full response schema instead of only example response & Typescript definitions. * * @default true */ showResponseSchema?: boolean; /** * Support other media types. */ mediaAdapters?: Record; /** * Customize page content. */ content?: { renderResponseTabs?: (options: ResponseTabsRenderOptions, ctx: RenderContext) => ReactNode; renderRequestTabs?: (options: RequestTabsRenderOptions, ctx: RenderContext) => ReactNode; renderAPIExampleLayout?: (slots: { selector: ReactNode; usageTabs: ReactNode; responseTabs: ReactNode; }, ctx: RenderContext) => ReactNode; /** * @param generators - codegens for API example usages */ renderAPIExampleUsageTabs?: (generators: CodeUsageGeneratorRegistry, ctx: RenderContext) => ReactNode; /** * renderer of the entire page's layout (containing all operations & webhooks UI) */ renderPageLayout?: (slots: { operations?: { item: OperationItem; children: ReactNode; }[]; webhooks?: { item: WebhookItem; children: ReactNode; }[]; }, ctx: RenderContext) => ReactNode; renderOperationLayout?: (slots: { header: ReactNode; description: ReactNode; apiExample: ReactNode; apiPlayground: ReactNode; authSchemes: ReactNode; parameters: ReactNode; body: ReactNode; responses: ReactNode; callbacks: ReactNode; }, context: { operation: OperationObject; method: HttpMethods; pathItem: PathItemObject; ctx: RenderContext; }) => ReactNode; renderWebhookLayout?: (slots: { header: ReactNode; description: ReactNode; authSchemes: ReactNode; parameters: ReactNode; body: ReactNode; requests: ReactNode; responses: ReactNode; callbacks: ReactNode; }) => ReactNode; }; /** * Info UI for JSON schemas. */ schemaUI?: { render?: (options: { root: ParsedSchema; readOnly?: boolean; writeOnly?: boolean; }, ctx: RenderContext) => ReactNode; /** * Show examples under the generated content of JSON schemas. * * @defaultValue false */ showExample?: boolean; }; /** * Customize API playground. */ playground?: PlaygroundClientOptions & { /** * @defaultValue true */ enabled?: boolean; /** * render a page-level provider (useful for handling auth) */ provider?: (props: { children: ReactNode; }) => ReactNode; /** * replace the renderer */ render?: (props: APIPlaygroundProps) => ReactNode; }; operation?: { APIExampleSelector?: FC<{ items: ExampleRequestItem[]; value: string | undefined; onValueChange: (id: string) => void; }>; }; components?: { Heading?: FC & { id: string; depth: number; }>; CodeBlock?: FC<{ lang: string; code: string; }>; Markdown?: FC<{ md: string; }>; }; /** * Set a prefix for `localStorage` keys. * * Useful when using multiple OpenAPI instances to prevent state conflicts. * * @defaultValue `fumadocs-openapi-` */ storageKeyPrefix?: string; /** @deprecated use `components.Heading` instead */ renderHeading?: (props: HTMLAttributes, depth: number) => ReactNode; /** @deprecated use `components.CodeBlock` instead */ renderCodeBlock?: (props: { lang: string; code: string; }) => ReactNode; /** @deprecated use `components.Markdown` instead */ renderMarkdown?: (md: string) => ReactNode; } type OpenAPIPageProps = OpenAPIPageProps_Spec | OpenAPIPageProps_Preloaded; type OpenAPIPageProps_Spec = Omit & { payload: { bundled: Document; proxyUrl?: string; }; }; type OpenAPIPageProps_Preloaded = GeneratedPageProps & { preloaded: { docs: Record; proxyUrl?: string; }; }; /** * Create `` (a client component). */ declare function createOpenAPIPage(options?: CreateOpenAPIPageOptions): FC; /** @deprecated Use `OpenAPIPageProps` instead */ type ApiPageProps = OpenAPIPageProps; //#endregion export { APIPlaygroundProps, ApiPageProps, CreateOpenAPIPageOptions, GenerateTypeScriptDefinitionsContext, OpenAPIPageProps, OpenAPIPageProps_Preloaded, OpenAPIPageProps_Spec, type OperationItem, type WebhookItem, createOpenAPIPage };