fix(zod-openapi): bump up Hono (#139)

* fix(zod-openapi): bump up Hono

* fix dependencies

* changeset
pull/140/head
Yusuke Wada 2023-08-24 17:10:26 +09:00 committed by GitHub
parent 687dc5a6a1
commit 991b85915a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 43 additions and 29 deletions

View File

@ -0,0 +1,5 @@
---
'@hono/zod-openapi': patch
---
fix: bump up Hono version

View File

@ -31,14 +31,14 @@
"zod": "3.*" "zod": "3.*"
}, },
"devDependencies": { "devDependencies": {
"hono": "^3.4.3", "hono": "^3.5.4",
"zod": "^3.22.1" "zod": "^3.22.1"
}, },
"dependencies": { "dependencies": {
"@asteasolutions/zod-to-openapi": "^5.5.0", "@asteasolutions/zod-to-openapi": "^5.5.0",
"@hono/zod-validator": "^0.1.7" "@hono/zod-validator": "^0.1.8"
}, },
"engines": { "engines": {
"node": ">=16.0.0" "node": ">=16.0.0"
} }
} }

View File

@ -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 type { OpenAPIObjectConfig } from '@asteasolutions/zod-to-openapi/dist/v3.0/openapi-generator'
import { zValidator } from '@hono/zod-validator' import { zValidator } from '@hono/zod-validator'
import { Hono } from 'hono' import { Hono } from 'hono'
import type { Context, Input, Schema, TypedResponse } from 'hono' import type {
import type { Env, Handler, MiddlewareHandler } from 'hono' Context,
Env,
Handler,
Input,
MiddlewareHandler,
Schema,
ToSchema,
TypedResponse,
} from 'hono'
import type { AnyZodObject, ZodSchema, ZodError } from 'zod' import type { AnyZodObject, ZodSchema, ZodError } from 'zod'
import { z, ZodType } from 'zod' import { z, ZodType } from 'zod'
@ -133,11 +141,11 @@ type ConvertPathType<T extends string> = T extends `${infer _}/{${infer Param}}$
? `/:${Param}` ? `/:${Param}`
: T : T
export class OpenAPIHono<E extends Env = Env, S = {}, BasePath extends string = '/'> extends Hono< export class OpenAPIHono<
E, E extends Env = Env,
S, S extends Schema = {},
BasePath BasePath extends string = '/'
> { > extends Hono<E, S, BasePath> {
#registry: OpenAPIRegistry #registry: OpenAPIRegistry
constructor() { constructor() {
@ -153,7 +161,7 @@ export class OpenAPIHono<E extends Env = Env, S = {}, BasePath extends string =
route: R, route: R,
handler: Handler<E, P, I, OutputType<R>>, handler: Handler<E, P, I, OutputType<R>>,
hook?: Hook<I, E, P, OutputType<R>> hook?: Hook<I, E, P, OutputType<R>>
): Hono<E, Schema<R['method'], P, I['in'], OutputType<R>>, BasePath> => { ): Hono<E, ToSchema<R['method'], P, I['in'], OutputType<R>>, BasePath> => {
this.#registry.registerPath(route) this.#registry.registerPath(route)
const validators: MiddlewareHandler[] = [] const validators: MiddlewareHandler[] = []

View File

@ -1,9 +1,7 @@
/* eslint-disable node/no-extraneous-import */ /* eslint-disable node/no-extraneous-import */
/* eslint-disable @typescript-eslint/no-explicit-any */ /* eslint-disable @typescript-eslint/no-explicit-any */
import type { Env } from 'hono' import type { Hono, Env, ToSchema } from 'hono'
import type { Hono } from 'hono'
import { describe, it, expect, expectTypeOf } from 'vitest' import { describe, it, expect, expectTypeOf } from 'vitest'
import type { Schema } from 'zod'
import { OpenAPIHono, createRoute, z } from '../src' import { OpenAPIHono, createRoute, z } from '../src'
describe('Basic - params', () => { describe('Basic - params', () => {
@ -435,22 +433,20 @@ describe('Types', () => {
it('Should return correct types', () => { it('Should return correct types', () => {
type H = Hono< type H = Hono<
Env, Env,
Schema<{ ToSchema<
'/posts': { 'post',
$post: { '/posts',
input: { {
json: { json: {
title: string title: string
id: number id: number
}
}
output: {
id: number
message: string
}
} }
},
{
id: number
message: string
} }
}>, >,
'/' '/'
> >
expectTypeOf(appRoutes).toMatchTypeOf<H> expectTypeOf(appRoutes).toMatchTypeOf<H>

View File

@ -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" resolved "https://registry.yarnpkg.com/hono/-/hono-3.2.6.tgz#b4927ed20b2edf165277f3e2b787a4e4948223f6"
integrity sha512-jUf9SgkTW/H3Pd9oPwFgf3j05RXUbILWm96WlHll56t2Jkv8tVXyfLeBzYwdTzB7JE/hx+DWMXrVJ06UdfcKng== integrity sha512-jUf9SgkTW/H3Pd9oPwFgf3j05RXUbILWm96WlHll56t2Jkv8tVXyfLeBzYwdTzB7JE/hx+DWMXrVJ06UdfcKng==
hono@^3.1.5, hono@^3.4.3: hono@^3.1.5:
version "3.4.3" version "3.4.3"
resolved "https://registry.yarnpkg.com/hono/-/hono-3.4.3.tgz#ab1db8777fa80341daf389979b7888da0786e3db" resolved "https://registry.yarnpkg.com/hono/-/hono-3.4.3.tgz#ab1db8777fa80341daf389979b7888da0786e3db"
integrity sha512-HbVxZh9yC3hV25+mFjUaM65t7g8ia2mXbhAGmVHA0r8+guizTJq1Cg4f2SmB5+JrviG0vaqOnWJ9U3O05aikbA== 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" resolved "https://registry.yarnpkg.com/hono/-/hono-3.5.2.tgz#83776c4f076c40f59850105af835a6a5609b7d07"
integrity sha512-HezADUIepgTpn+LSHNU2vZd4V2wcFDkObycShxhR37eXwQXgjev9FHsxBpDkvPqGQLn3YAPiC3GNVZVUsbcwFg== 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: hosted-git-info@^2.1.4:
version "2.8.9" version "2.8.9"
resolved "https://registry.yarnpkg.com/hosted-git-info/-/hosted-git-info-2.8.9.tgz#dffc0bf9a21c02209090f2aa69429e1414daf3f9" resolved "https://registry.yarnpkg.com/hosted-git-info/-/hosted-git-info-2.8.9.tgz#dffc0bf9a21c02209090f2aa69429e1414daf3f9"