feat(zod-openapi): Make it possible to do method chaining even for do… (#260)

* feat(zod-openapi): Make it possible to do method chaining even for doc methods

* fix: Fix incorrect generics type specification
pull/263/head
Karibash 2023-11-18 06:04:56 +09:00 committed by GitHub
parent 4c5b5be848
commit ba83a268e0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 17 additions and 6 deletions

View File

@ -0,0 +1,5 @@
---
'@hono/zod-openapi': patch
---
Make it possible to do method chaining even for doc methods

View File

@ -277,18 +277,24 @@ export class OpenAPIHono<
return document return document
} }
doc = (path: string, config: OpenAPIObjectConfig) => { doc = <P extends string>(
this.get(path, (c) => { path: P,
config: OpenAPIObjectConfig
): OpenAPIHono<E, S & ToSchema<'get', P, {}, {}>, BasePath> => {
return this.get(path, (c) => {
const document = this.getOpenAPIDocument(config) const document = this.getOpenAPIDocument(config)
return c.json(document) return c.json(document)
}) }) as any
} }
doc31 = (path: string, config: OpenAPIObjectConfig) => { doc31 = <P extends string>(
this.get(path, (c) => { path: P,
config: OpenAPIObjectConfig
): OpenAPIHono<E, S & ToSchema<'get', P, {}, {}>, BasePath> => {
return this.get(path, (c) => {
const document = this.getOpenAPI31Document(config) const document = this.getOpenAPI31Document(config)
return c.json(document) return c.json(document)
}) }) as any
} }
route< route<