fix(zod-openapi): bump up Hono (#139)
* fix(zod-openapi): bump up Hono * fix dependencies * changesetpull/140/head
parent
687dc5a6a1
commit
991b85915a
|
@ -0,0 +1,5 @@
|
|||
---
|
||||
'@hono/zod-openapi': patch
|
||||
---
|
||||
|
||||
fix: bump up Hono version
|
|
@ -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"
|
||||
}
|
||||
}
|
||||
}
|
|
@ -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 string> = T extends `${infer _}/{${infer Param}}$
|
|||
? `/:${Param}`
|
||||
: T
|
||||
|
||||
export class OpenAPIHono<E extends Env = Env, S = {}, BasePath extends string = '/'> extends Hono<
|
||||
E,
|
||||
S,
|
||||
BasePath
|
||||
> {
|
||||
export class OpenAPIHono<
|
||||
E extends Env = Env,
|
||||
S extends Schema = {},
|
||||
BasePath extends string = '/'
|
||||
> extends Hono<E, S, BasePath> {
|
||||
#registry: OpenAPIRegistry
|
||||
|
||||
constructor() {
|
||||
|
@ -153,7 +161,7 @@ export class OpenAPIHono<E extends Env = Env, S = {}, BasePath extends string =
|
|||
route: R,
|
||||
handler: Handler<E, P, I, 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)
|
||||
|
||||
const validators: MiddlewareHandler[] = []
|
||||
|
|
|
@ -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<H>
|
||||
|
|
|
@ -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"
|
||||
|
|
Loading…
Reference in New Issue