Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 3 commits into from
Aug 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/strange-pumas-tickle.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@hono/zod-openapi': patch
---

fix: bump up Hono version
6 changes: 3 additions & 3 deletions packages/zod-openapi/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
}
}
24 changes: 16 additions & 8 deletions packages/zod-openapi/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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'

Expand Down Expand Up @@ -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() {
Expand All @@ -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[] = []
Expand Down
30 changes: 13 additions & 17 deletions packages/zod-openapi/test/index.test.ts
Original file line number Diff line number Diff line change
@@ -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', () => {
Expand Down Expand Up @@ -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>
Expand Down
7 changes: 6 additions & 1 deletion yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -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==
Expand All @@ -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"
Expand Down
Loading