import {
	createRoute,
	type OpenAPIHono,
	type RouteConfig,
} from '@hono/zod-openapi';
import type { Handler, Hono } from 'hono';

/**
 * Register an endpoint whose OpenAPI contract is derived from Zod schemas.
 */
export function zodOpenApiRoute(
	app: Hono,
	route: RouteConfig,
	handler: Handler,
) {
	const openApiApp = app as OpenAPIHono;
	return openApiApp.openapi(createRoute(route), handler as never);
}
