swagger-ui and @hono/zod-openapi mismatch
Hello,
I'm trying to make the swagger-ui middleware work with the @hono/zod-openapi package. It does work when I run my project but I get this deno-ts error in VS code and I wondered if it was possible to solve it?
Thanks for your help π
24 Replies
try -> app.get("/ui", swaggerUI({ url: "/api/docs" }));
i tried it unfortunately didn't change anything π
could be a hono version issue (e.g., if you're using
@hono/zod-openapi
but MiddlewareHandler<Env, "/api/ui", {}> seems funky. where's that path type coming from?i'm using these dependencies:
and in my deno.json:
have you taken a look at this? https://github.com/honojs/middleware/tree/main/packages/zod-openapi#combining-with-hono
actually i don't have a reference in my code to hono package i could remove it i think
yes indeed i'm not using it, i removed it, still the same error message
it's not blocking but just I'd like to understand why I have this ts error
you removed the package?
the issue is with this type
Context<Env, "/api/ui", {}>, so the place to start would be wherever that comes from
how is app defined?yes

can you share your
tsconfig?
it could have something to do w JSR, tbhi don't even have one lmao
since i use deno i think it's not really needed
rip
might be worth posting this thread in #deno
ok will do now, thanks β€οΈ
actually could these options in my deno.json explain the ts error i get?
"compilerOptions": {
"jsx": "precompile",
"jsxImportSource": "hono/jsx"
}
i think these are set by default when creating an app with deno:
deno init --npm hono@latest my-app
i don't think so. the issue you're facing has to do with how
Context is typed. jsx settings shouldn't affect it at all
those are just hono defaults
it might be worth creating a minimal reproducible example + creating an issue on github, probably the middleware repo
or, try posting in the deno server, if you haven't alreadyI will check tonight also if thatβs not my typescript which could be broken even if I think Deno comes with its own bundled tsc
You tested this on Node right?
bun, but yeah
Ok thanks
yeah, that's the thing. i have 0 experience with deno or jsr, but i know that folks have occasionally come in with type issues related to both
unfortunately there aren't a lot of folks on the server who use those tools
could be worth a try searching through the server history though. any previous solutions might be helpful
Iβll give it a try I have a few errors with typescript on drizzle too, unsure if it comes from Deno itself or my setup
i'm happy to take a look at those as well
Iβll share them tonight, thank you so much for the help
ok by reading my code i realize i was a dummy
i can fix my drizzle issues, but for the hono swagger-ui / zod-openapi compatibility idk
i opened that https://github.com/32cls/repr_hono
GitHub
GitHub - 32cls/repr_hono
Contribute to 32cls/repr_hono development by creating an account on GitHub.
so i'm thinking the issue relates to a mix of jsr + npm dependencies, but i don't really know. i can repro with deno though
if you also use npm for
@hono/swagger-ui the error goes away
my deno.json
you're right
thank you very much, it seems i also did not enable deno vscode extension so the error was still showing up
but now it's fixed, thank you again π