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

Swagger + tRPC #956

Open
manazoid opened this issue Dec 21, 2024 · 0 comments
Open

Swagger + tRPC #956

manazoid opened this issue Dec 21, 2024 · 0 comments
Labels
bug Something isn't working

Comments

@manazoid
Copy link

What version of Elysia is running?

"version": "1.1.26"

What platform is your computer?

Microsoft Windows NT 10.0.19044.0 x64

What steps can reproduce the bug?

initial project with elysia
bun create elysia app
install both tRPC and swagger plug-ins
bun add @elysiajs/swagger @elysiajs/trpc @trpc/server @elysiajs/websocket
apply both middlewares

// index.ts
import {Elysia} from 'elysia';
import {appRouter} from "./router";
import {trpc} from "@elysiajs/trpc";
import swagger from "@elysiajs/swagger";

const app = new Elysia();
app.use(swagger())
app.use(trpc(appRouter))

app.listen(3000, () => {
  console.log('Server is running on http://localhost:3000');
});
// router.ts
const t = initTRPC.create();
const p = t.procedure
export const appRouter = t.router({
  hello: p
    .input(z.object({name: z.string()}))
    .output(z.object({message: z.string()}))
    .query(({input}) => {
      return {message: `Hello, ${input.name}!`};
    }),
  add: p
    .input(z.object({a: z.number(), b: z.number()}))
    .output(z.object({result: z.number()}))
    .mutation(({input}) => {
      return {result: input.a + input.b};
    }),
});

What is the expected behavior?

I see every handle equavivalent in my swagger docs (GET for query and POST for mutation)

image

What do you see instead?

Empty docs

image

Additional information

I used the setup of chaos middlewares and nginx + traefik setup to see the docs with elysia. But it's not tRPC server anymore, it's typed REST. Is it possible to fix middleware or something?

Here's a repo with this crazy setup (I think it done wrong):

https://gitlab.com/manazoid/trpc-swagger-for-elysiajs

Have you try removing the node_modules and bun.lockb and try again yet?

yes

@manazoid manazoid added the bug Something isn't working label Dec 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant