OpenAPI docs generate invalid request examples for oRPC endpoints #1584
-
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 1 reply
-
|
Hi @hammadmajid! I'm Dosu and I'm helping the unnoq's Org team. The core issue here is a routing mismatch — your cURL requests are hitting Why the How to fix it: The
app.all("/api/*", async (c, next) => {
const { matched, response } = await openAPIHandler.handle(c.req.raw, {
prefix: '/api',
context: { env: c.env },
})
if (matched) return c.newResponse(response.body, response)
await next()
})Then
To answer your three questions directly:
The idiomatic pattern is to run both handlers side by side: To reply, just mention @dosu. Docs are dead. Just use Dosu. |
Beta Was this translation helpful? Give feedback.
-
|
You are define incorrect server in openapi spec, you should point to OpenAPIHandler instead RPCHandler |
Beta Was this translation helpful? Give feedback.
-
|
Fixed it by serving the endpoints with // remove this import
// import { RPCHandler } from '@orpc/server/fetch'
app.use('/rpc/*', async (c, next) => {
const { matched, response } = await openAPIHandler.handle(c.req.raw, {
prefix: '/rpc',
context: {}
})
if (matched) {
return c.newResponse(response.body, response)
}
await next()
})After switching to Credit to |
Beta Was this translation helpful? Give feedback.

Fixed it by serving the endpoints with
OpenAPIHandlerinstead ofRPCHandler:After switching to
OpenAPIHandler, the endpoints accept the request body directly (without thejsonwrapper), and the generated OpenAPI/Scalar examples work as expected.Credit to
dinwwwhon Discord for pointing me in the right direction.