diff --git a/.changeset/strange-pumas-tickle.md b/.changeset/strange-pumas-tickle.md new file mode 100644 index 00000000..17ab2cb8 --- /dev/null +++ b/.changeset/strange-pumas-tickle.md @@ -0,0 +1,5 @@ +--- +'@hono/zod-openapi': patch +--- + +fix: bump up Hono version diff --git a/packages/zod-openapi/package.json b/packages/zod-openapi/package.json index 0f424b2f..dd3a4ab2 100644 --- a/packages/zod-openapi/package.json +++ b/packages/zod-openapi/package.json @@ -31,14 +31,14 @@ "zod": "3.*" }, "devDependencies": { - "hono": "^3.4.3", + "hono": "^3.5.4", "zod": "^3.22.1" }, "dependencies": { "@asteasolutions/zod-to-openapi": "^5.5.0", - "@hono/zod-validator": "^0.1.7" + "@hono/zod-validator": "^0.1.8" }, "engines": { "node": ">=16.0.0" } -} +} \ No newline at end of file diff --git a/packages/zod-openapi/src/index.ts b/packages/zod-openapi/src/index.ts index 3570772a..bfc1de50 100644 --- a/packages/zod-openapi/src/index.ts +++ b/packages/zod-openapi/src/index.ts @@ -11,8 +11,16 @@ import { extendZodWithOpenApi } from '@asteasolutions/zod-to-openapi' import type { OpenAPIObjectConfig } from '@asteasolutions/zod-to-openapi/dist/v3.0/openapi-generator' import { zValidator } from '@hono/zod-validator' import { Hono } from 'hono' -import type { Context, Input, Schema, TypedResponse } from 'hono' -import type { Env, Handler, MiddlewareHandler } from 'hono' +import type { + Context, + Env, + Handler, + Input, + MiddlewareHandler, + Schema, + ToSchema, + TypedResponse, +} from 'hono' import type { AnyZodObject, ZodSchema, ZodError } from 'zod' import { z, ZodType } from 'zod' @@ -133,11 +141,11 @@ type ConvertPathType = T extends `${infer _}/{${infer Param}}$ ? `/:${Param}` : T -export class OpenAPIHono extends Hono< - E, - S, - BasePath -> { +export class OpenAPIHono< + E extends Env = Env, + S extends Schema = {}, + BasePath extends string = '/' +> extends Hono { #registry: OpenAPIRegistry constructor() { @@ -153,7 +161,7 @@ export class OpenAPIHono>, hook?: Hook> - ): Hono>, BasePath> => { + ): Hono>, BasePath> => { this.#registry.registerPath(route) const validators: MiddlewareHandler[] = [] diff --git a/packages/zod-openapi/test/index.test.ts b/packages/zod-openapi/test/index.test.ts index b3c0539f..91cecd80 100644 --- a/packages/zod-openapi/test/index.test.ts +++ b/packages/zod-openapi/test/index.test.ts @@ -1,9 +1,7 @@ /* eslint-disable node/no-extraneous-import */ /* eslint-disable @typescript-eslint/no-explicit-any */ -import type { Env } from 'hono' -import type { Hono } from 'hono' +import type { Hono, Env, ToSchema } from 'hono' import { describe, it, expect, expectTypeOf } from 'vitest' -import type { Schema } from 'zod' import { OpenAPIHono, createRoute, z } from '../src' describe('Basic - params', () => { @@ -435,22 +433,20 @@ describe('Types', () => { it('Should return correct types', () => { type H = Hono< Env, - Schema<{ - '/posts': { - $post: { - input: { - json: { - title: string - id: number - } - } - output: { - id: number - message: string - } + ToSchema< + 'post', + '/posts', + { + json: { + title: string + id: number } + }, + { + id: number + message: string } - }>, + >, '/' > expectTypeOf(appRoutes).toMatchTypeOf diff --git a/yarn.lock b/yarn.lock index 99e6b4c7..6ec8b8c9 100644 --- a/yarn.lock +++ b/yarn.lock @@ -5823,7 +5823,7 @@ hono@^3.0.0, hono@^3.0.3, hono@^3.1.0, hono@^3.1.2, hono@^3.2.6: resolved "https://registry.yarnpkg.com/hono/-/hono-3.2.6.tgz#b4927ed20b2edf165277f3e2b787a4e4948223f6" integrity sha512-jUf9SgkTW/H3Pd9oPwFgf3j05RXUbILWm96WlHll56t2Jkv8tVXyfLeBzYwdTzB7JE/hx+DWMXrVJ06UdfcKng== -hono@^3.1.5, hono@^3.4.3: +hono@^3.1.5: version "3.4.3" resolved "https://registry.yarnpkg.com/hono/-/hono-3.4.3.tgz#ab1db8777fa80341daf389979b7888da0786e3db" integrity sha512-HbVxZh9yC3hV25+mFjUaM65t7g8ia2mXbhAGmVHA0r8+guizTJq1Cg4f2SmB5+JrviG0vaqOnWJ9U3O05aikbA== @@ -5838,6 +5838,11 @@ hono@^3.5.2: resolved "https://registry.yarnpkg.com/hono/-/hono-3.5.2.tgz#83776c4f076c40f59850105af835a6a5609b7d07" integrity sha512-HezADUIepgTpn+LSHNU2vZd4V2wcFDkObycShxhR37eXwQXgjev9FHsxBpDkvPqGQLn3YAPiC3GNVZVUsbcwFg== +hono@^3.5.4: + version "3.5.4" + resolved "https://registry.yarnpkg.com/hono/-/hono-3.5.4.tgz#66057d4c1ee127faafa087168af6d569ab25f5e7" + integrity sha512-GrRBIJhZ+tG+8RtoyPQjvqPGwppERmayyTiPKano4egmpkJf1XiptESUYK5vKHICNaJksAKB9jzy1CmOdQENPA== + hosted-git-info@^2.1.4: version "2.8.9" resolved "https://registry.yarnpkg.com/hosted-git-info/-/hosted-git-info-2.8.9.tgz#dffc0bf9a21c02209090f2aa69429e1414daf3f9"