fumadocs-openapi
Version:
Generate MDX docs for your OpenAPI spec
95 lines (94 loc) • 3.33 kB
TypeScript
import { ParsedSchema } from "../utils/schema.js";
import { RequestData } from "../requests/types.js";
import { FetchResult } from "./fetcher.js";
import { ParameterField, SecurityEntry } from "./index.js";
import { SchemaScope } from "./schema.js";
import { ComponentProps, FC, ReactNode } from "react";
import { FieldPath, UseControllerProps, UseControllerReturn } from "react-hook-form";
import * as react_jsx_runtime0 from "react/jsx-runtime";
//#region src/playground/client.d.ts
interface FormValues {
path: Record<string, unknown>;
query: Record<string, unknown>;
header: Record<string, unknown>;
cookie: Record<string, unknown>;
body: unknown;
/**
* Store the cached encoded request data, do not modify it.
*/
_encoded?: RequestData;
}
interface PlaygroundClientProps extends ComponentProps<'form'>, SchemaScope {
route: string;
method: string;
parameters?: ParameterField[];
securities: SecurityEntry[][];
body?: {
schema: ParsedSchema;
mediaType: string;
};
/**
* Resolver for $ref schemas you've passed
*/
references: Record<string, ParsedSchema>;
proxyUrl?: string;
}
interface PlaygroundClientOptions {
/**
* transform fields for auth-specific parameters (e.g. header)
*/
transformAuthInputs?: (fields: AuthField[]) => AuthField[];
/**
* Request timeout in seconds (default: 10s)
*/
requestTimeout?: number;
components?: Partial<{
ResultDisplay: FC<{
data: FetchResult;
}>;
}>;
/**
* render the paremeter inputs of API endpoint.
*
* It uses `react-hook-form`, you can use either:
* - the library itself, with types from `fumadocs-openapi/playground/client`.
* - the `Custom.useController()` from `fumadocs-openapi/playground/client`.
*
* Recommended types packages: `json-schema-typed`, `openapi-types`.
*/
renderParameterField?: (fieldName: FieldPath<FormValues>, param: ParameterField) => ReactNode;
/**
* render the input for API endpoint body.
*
* @see renderParameterField for customisation tips
*/
renderBodyField?: (fieldName: 'body', info: {
schema: ParsedSchema;
mediaType: string;
}) => ReactNode;
}
declare function PlaygroundClient({
route,
method,
securities,
parameters,
body,
references,
proxyUrl,
writeOnly,
readOnly,
...rest
}: PlaygroundClientProps): react_jsx_runtime0.JSX.Element;
interface AuthField {
fieldName: string;
defaultValue: unknown;
original?: SecurityEntry;
children: ReactNode;
mapOutput?: (values: unknown) => unknown;
}
declare const Custom: {
useController<TName extends FieldPath<FormValues> = "path" | "query" | "header" | "cookie" | "body" | "_encoded" | `path.${string}` | `query.${string}` | `header.${string}` | `cookie.${string}` | "_encoded.path" | "_encoded.query" | "_encoded.header" | "_encoded.cookie" | "_encoded.body" | `_encoded.path.${string}` | `_encoded.query.${string}` | `_encoded.header.${string}` | `_encoded.cookie.${string}` | "_encoded.method" | "_encoded.bodyMediaType", TTransformedValues = FormValues>(props: UseControllerProps<FormValues, TName, TTransformedValues>): UseControllerReturn<FormValues, TName>;
};
//#endregion
export { AuthField, Custom, FormValues, PlaygroundClientOptions, PlaygroundClientProps, PlaygroundClient as default };
//# sourceMappingURL=client.d.ts.map