mirror of
https://github.com/hanzoai/trpc-openapi.git
synced 2026-10-30 18:18:55 +00:00
40 lines
1.6 KiB
TypeScript
40 lines
1.6 KiB
TypeScript
import { ZodOpenApiObject, ZodOpenApiPathsObject } from 'zod-openapi';
|
|
import { ZodSchema } from 'zod';
|
|
import { OpenApiMeta, type OpenAPIObject, OpenApiRouter, type SecuritySchemeObject } from '../types';
|
|
export interface GenerateOpenApiDocumentOptions<TMeta = Record<string, unknown>> {
|
|
title: string;
|
|
description?: string;
|
|
version: string;
|
|
openApiVersion?: ZodOpenApiObject['openapi'];
|
|
baseUrl: string;
|
|
docsUrl?: string;
|
|
tags?: string[];
|
|
securitySchemes?: Record<string, SecuritySchemeObject>;
|
|
paths?: ZodOpenApiPathsObject;
|
|
/**
|
|
* Optional filter function to include/exclude procedures from the generated OpenAPI document.
|
|
*
|
|
* The function receives a context object with the procedure's metadata as `ctx.metadata`.
|
|
* Return `true` to include the procedure, or `false` to exclude it from the OpenAPI output.
|
|
*
|
|
* @example
|
|
* filter: ({ metadata }) => metadata.isPublic === true
|
|
*/
|
|
filter?: (ctx: {
|
|
metadata: {
|
|
openapi: NonNullable<OpenApiMeta['openapi']>;
|
|
} & TMeta;
|
|
}) => boolean;
|
|
/**
|
|
* Optional object containing Zod schemas to be included in the OpenAPI document's components/schemas section.
|
|
*
|
|
* @example
|
|
* defs: {
|
|
* UserSchema: z.object({ id: z.string(), name: z.string() }),
|
|
* ProductSchema: z.object({ id: z.string(), price: z.number() })
|
|
* }
|
|
*/
|
|
defs?: Record<string, ZodSchema>;
|
|
}
|
|
export declare const generateOpenApiDocument: <TMeta = Record<string, unknown>>(appRouter: OpenApiRouter, opts: GenerateOpenApiDocumentOptions<TMeta>) => OpenAPIObject;
|
|
//# sourceMappingURL=index.d.ts.map
|