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

type error when set basePath to OpenAPIHono #174

Closed
sor4chi opened this issue Sep 23, 2023 · 1 comment · Fixed by #179
Closed

type error when set basePath to OpenAPIHono #174

sor4chi opened this issue Sep 23, 2023 · 1 comment · Fixed by #179

Comments

@sor4chi
Copy link
Contributor

sor4chi commented Sep 23, 2023

This will be ok

const app = new OpenAPIHono()
app.openapi(route, (c) => c.jsonT({ message: 'Hello' }))

But this will be error

const app = new OpenAPIHono().basePath("/hoge")
app.openapi(route, (c) => c.jsonT({ message: 'Hello' }))

this won't be type error, but basePath doesn't work

const app = new OpenAPIHono()
app.basePath("/hoge")
app.openapi(route, (c) => c.jsonT({ message: 'Hello' }))
All Example Code
import { OpenAPIHono, createRoute } from "@hono/zod-openapi";

const route = createRoute({
  method: 'get',
  path: '/message',
  responses: {
    200: {
      description: 'Get message',
    },
  },
})

const app = new OpenAPIHono()
app.basePath('/api')

app.openapi(route, (c) => c.jsonT({ message: 'Hello' }))

export default app;
@sor4chi
Copy link
Contributor Author

sor4chi commented Sep 25, 2023

Actually, I want to extend Hono's Context like (c.webSocket, c.storage, etc...) in hono-do. But this project includes basePath internally.
I found the same approach in OpenAPIHono so I throw this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant