import type { Context, Hono } from "hono"; import { generateSpecs, type GenerateSpecOptions } from "hono-openapi"; import type { AppEnv } from "@/worker/types"; export function openApiOptions(c?: Context): Partial { const serverUrl = c ? new URL(c.req.url).origin : "https://dav.example.com"; return { documentation: { openapi: "3.1.0", info: { title: "dab JSON API", version: "0.1.0", description: "Control-plane JSON API for dab DAV service.", }, servers: [{ url: serverUrl }], components: { securitySchemes: { cookieSession: { type: "apiKey", in: "cookie", name: "__Host-dab_session", }, }, }, }, }; } export function buildOpenApiDocument(app: Hono, c?: Context) { return generateSpecs(app, openApiOptions(c), c); }