diff --git a/.changeset/tame-dodos-grab.md b/.changeset/tame-dodos-grab.md new file mode 100644 index 00000000..ccb1b237 --- /dev/null +++ b/.changeset/tame-dodos-grab.md @@ -0,0 +1,5 @@ +--- +'@hono/zod-openapi': patch +--- + +Make it possible to do method chaining even for doc methods diff --git a/packages/zod-openapi/src/index.ts b/packages/zod-openapi/src/index.ts index 08f51a59..56f29161 100644 --- a/packages/zod-openapi/src/index.ts +++ b/packages/zod-openapi/src/index.ts @@ -28,6 +28,7 @@ import type { import type { MergePath, MergeSchemaPath } from 'hono/types' import type { RemoveBlankRecord } from 'hono/utils/types' import { mergePath } from 'hono/utils/url' +import type { OpenAPIObject } from 'openapi3-ts/oas30' import type { AnyZodObject, ZodSchema, ZodError } from 'zod' import { z, ZodType } from 'zod' @@ -277,18 +278,24 @@ export class OpenAPIHono< return document } - doc = (path: string, config: OpenAPIObjectConfig) => { - this.get(path, (c) => { + doc =

( + path: P, + config: OpenAPIObjectConfig + ): OpenAPIHono, BasePath> => { + return this.get(path, (c) => { const document = this.getOpenAPIDocument(config) return c.json(document) - }) + }) as any } - doc31 = (path: string, config: OpenAPIObjectConfig) => { - this.get(path, (c) => { + doc31 =

( + path: P, + config: OpenAPIObjectConfig + ): OpenAPIHono, BasePath> => { + return this.get(path, (c) => { const document = this.getOpenAPI31Document(config) return c.json(document) - }) + }) as any } route<