trpc-openapi with t3-stack

I am wondering if anyone has any experience adding trpc-openapi to the t3stack. i have followed the basic steps of the readme guide and when i add a trpc-openapi handler to my app i get "tRPC failed on <no-path>: Not found" when calling a trpc procedure. this is my new [trpc].ts file
import { createNextApiHandler } from "@trpc/server/adapters/next";
import { env } from "../../../env.mjs";
import { appRouter } from "../../../server/api/root";
import { createTRPCContext } from "../../../server/api/trpc";

import { createOpenApiNextHandler } from 'trpc-openapi';

// export API handler
export default createOpenApiNextHandler({

router: appRouter,
createContext: createTRPCContext,
onError:
env.NODE_ENV === "development"
? ({ path, error }) => {
console.error(
`❌ tRPC failed on ${path ?? "<no-path>"}: ${error.message}`
);
}
: undefined,
});

// Disable body parser - we want raw body
export const config = {
api: {
bodyParser: false,
},
}
import { createNextApiHandler } from "@trpc/server/adapters/next";
import { env } from "../../../env.mjs";
import { appRouter } from "../../../server/api/root";
import { createTRPCContext } from "../../../server/api/trpc";

import { createOpenApiNextHandler } from 'trpc-openapi';

// export API handler
export default createOpenApiNextHandler({

router: appRouter,
createContext: createTRPCContext,
onError:
env.NODE_ENV === "development"
? ({ path, error }) => {
console.error(
`❌ tRPC failed on ${path ?? "<no-path>"}: ${error.message}`
);
}
: undefined,
});

// Disable body parser - we want raw body
export const config = {
api: {
bodyParser: false,
},
}
Another question i have is how do i test a endpoint when using the t3stack. in my routers folder i have a router called accountRouter which has a procedure called register. would my request to that procedure which i have added trpc-openapi to be something like "http://localhost:3000/api/accountRouter/register/{paramater}?{value}" ?
1 Reply
Want results from more Discord servers?
Add your server