/** * Fastify-specific service and schema-types generators for openapi-server. * * When framework=fastify and input_schema is configured, these generators replace * the generic service.ts and emit an additional schema-types.ts file that derives * TypeScript types from z.infer of the user-owned Zod schemas. Both service.ts and * router.ts then use these z.infer aliases, eliminating all body/response casts. */ import type { OpenAPIV3_1 } from 'openapi-types'; import type { GeneratedFile } from 'openapi-zod-ts'; /** Minimal shape needed to emit service method headers arg. */ export interface ServiceHeaderParam { /** Raw header name as it appears in the spec (original casing). */ rawName: string; required: boolean; } /** Minimal shape needed to emit service method cookies arg. */ export interface ServiceCookieParam { rawName: string; required: boolean; } export interface FastifyServiceOptions { schemaNames: Set; schemaImportPath: string; contextType?: string; } /** * Emit schema-types.ts: a generated file of z.infer aliases for every schema * in schemaNames. Both router.ts and service.ts import from this file instead * of models.ts, making body/response casts unnecessary. * * z.infer is equivalent to z.output: it reflects the post-validation, post-transform * shape. This is the correct type for a Fastify handler, where ZodTypeProvider has * already run the schema through .parse(). When a schema uses .transform(), .default(), * or coercion, this type will differ from the hand-authored models.ts interfaces. * * Alias naming: strip the trailing 'Schema' suffix. * Example: PetSchema -> export type Pet = z.infer */ export declare function generateFastifyTypes(schemaNames: Set, schemaImportPath: string): GeneratedFile; /** * Emit service.ts for the Fastify zero-cast path. * * Method signatures use z.infer-derived alias types (from schema-types.ts) wherever * a matching schema exists. When no schema is available, the type falls back to unknown. * This matches what ZodTypeProvider infers for req.body and reply.send, so the generated * router.ts can pass req.body directly without any `as ModelType` cast. */ export declare function generateFastifyTypedService(spec: OpenAPIV3_1.Document, options: FastifyServiceOptions): GeneratedFile; //# sourceMappingURL=fastify-service.d.ts.map