parent
6bdbf88854
commit
b1f8a5325c
|
@ -0,0 +1,5 @@
|
||||||
|
---
|
||||||
|
'@hono/zod-openapi': patch
|
||||||
|
---
|
||||||
|
|
||||||
|
fix: base path not included in client types
|
|
@ -250,7 +250,7 @@ export class OpenAPIHono<
|
||||||
: HandlerAllResponse<OutputType<R>>
|
: HandlerAllResponse<OutputType<R>>
|
||||||
>,
|
>,
|
||||||
hook: Hook<I, E, P, OutputType<R>> | undefined = this.defaultHook
|
hook: Hook<I, E, P, OutputType<R>> | undefined = this.defaultHook
|
||||||
): OpenAPIHono<E, S & ToSchema<R['method'], P, I['in'], OutputType<R>>, BasePath> => {
|
): OpenAPIHono<E, S & ToSchema<R['method'], MergePath<BasePath, P>, I['in'], OutputType<R>>, BasePath> => {
|
||||||
this.openAPIRegistry.registerPath(route)
|
this.openAPIRegistry.registerPath(route)
|
||||||
|
|
||||||
const validators: MiddlewareHandler[] = []
|
const validators: MiddlewareHandler[] = []
|
||||||
|
|
|
@ -44,7 +44,7 @@ describe('Types', () => {
|
||||||
const appRoutes = app.openapi(route, (c) => {
|
const appRoutes = app.openapi(route, (c) => {
|
||||||
const data = c.req.valid('json')
|
const data = c.req.valid('json')
|
||||||
assertType<number>(data.id)
|
assertType<number>(data.id)
|
||||||
return c.jsonT({
|
return c.json({
|
||||||
id: data.id,
|
id: data.id,
|
||||||
message: 'Success',
|
message: 'Success',
|
||||||
})
|
})
|
||||||
|
@ -70,7 +70,7 @@ describe('Types', () => {
|
||||||
'/'
|
'/'
|
||||||
>
|
>
|
||||||
expectTypeOf(appRoutes).toMatchTypeOf<H>()
|
expectTypeOf(appRoutes).toMatchTypeOf<H>()
|
||||||
})
|
});
|
||||||
})
|
})
|
||||||
|
|
||||||
describe('Input types', () => {
|
describe('Input types', () => {
|
||||||
|
|
|
@ -832,6 +832,16 @@ describe('basePath()', () => {
|
||||||
expect(app.defaultHook).toBeDefined()
|
expect(app.defaultHook).toBeDefined()
|
||||||
expect(app.defaultHook).toBe(defaultHook)
|
expect(app.defaultHook).toBe(defaultHook)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
it('Should include base path in typings', () => {
|
||||||
|
const routes = new OpenAPIHono()
|
||||||
|
.basePath('/api')
|
||||||
|
.openapi(route, (c) => c.json({ message: 'Hello' }))
|
||||||
|
|
||||||
|
const client = hc<typeof routes>('http://localhost/')
|
||||||
|
|
||||||
|
expect(client.api.message.$url().pathname).toBe('/api/message')
|
||||||
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
describe('With hc', () => {
|
describe('With hc', () => {
|
||||||
|
|
Loading…
Reference in New Issue