From 9aefddc45d048e5e51eb36d81cb878c62a72ba9f Mon Sep 17 00:00:00 2001 From: Nico Franke Date: Thu, 28 Sep 2023 23:08:26 +0200 Subject: [PATCH] fix(zod-openapi): properly convert openapi path type to hono (#182) * fix: properly convert openapi path type to hono * chore: add changeset --- .changeset/slimy-singers-begin.md | 5 +++++ packages/zod-openapi/src/index.ts | 4 ++-- 2 files changed, 7 insertions(+), 2 deletions(-) create mode 100644 .changeset/slimy-singers-begin.md diff --git a/.changeset/slimy-singers-begin.md b/.changeset/slimy-singers-begin.md new file mode 100644 index 00000000..ac4a4ddf --- /dev/null +++ b/.changeset/slimy-singers-begin.md @@ -0,0 +1,5 @@ +--- +'@hono/zod-openapi': patch +--- + +properly convert openapi path type to hono diff --git a/packages/zod-openapi/src/index.ts b/packages/zod-openapi/src/index.ts index 04362b44..4ba8d745 100644 --- a/packages/zod-openapi/src/index.ts +++ b/packages/zod-openapi/src/index.ts @@ -145,8 +145,8 @@ type Hook = ( c: Context ) => TypedResponse | Promise> | void -type ConvertPathType = T extends `${infer _}/{${infer Param}}${infer _}` - ? `/:${Param}` +type ConvertPathType = T extends `${infer Start}/{${infer Param}}${infer Rest}` + ? `${Start}/:${Param}${ConvertPathType}` : T type HandlerResponse = TypedResponse | Promise>