Input schema for path params #942
Replies: 4 comments 9 replies
-
Hi @ajiohjesse! I'm Dosu and I’m helping the orpc team. Your contract definition is correct—the error is actually a strict requirement enforced by the OpenApiHandler. When you use dynamic path params (like In your case, If your schema matches the path params and all are required, OpenAPI generation should succeed. If you have additional properties in your schema, the generator now correctly separates them, so only the dynamic params need to be required [PR #814]. To reply, just mention @dosu. How did I do? Good | Irrelevant | Incorrect | Verbose | Hallucination | Report 🐛 | Other |
Beta Was this translation helpful? Give feedback.
-
@dosu I m on the latest version of orpc (1.8.5). The openapi generation is still failing. Changing the find definition to
now gives the following error:
|
Beta Was this translation helpful? Give feedback.
-
Make sure you configure |
Beta Was this translation helpful? Give feedback.
-
I am facing same issue.
const handler = new OpenAPIHandler(router, {
plugins: [
new CORSPlugin({
origin: env.API_ORIGIN || "http://localhost:3001",
allowHeaders: ["Content-Type", "Authorization", "Cookie"],
credentials: true,
allowMethods: ["GET", "POST", "PATCH", "DELETE", "OPTIONS"],
}),
new RequestHeadersPlugin(),
new ZodSmartCoercionPlugin(),
],
interceptors: [
onError((error) => {
logger.error("Request error:", error);
}),
],
});
const openAPIGenerator = new OpenAPIGenerator({
schemaConverters: [new ZodToJsonSchemaConverter()],
}); getGroupById: base
.route({
description: "Retrieve a single lead group by id",
method: "GET",
path: "/{id}",
inputStructure: "detailed",
})
.input(
z.object({
params: z.object({ id: z.string() }),
query: z.object({}).optional(),
body: z.object({}).optional(),
headers: z.object({}).optional(),
}),
)
.output(z.array(ContactSchema).nullable()),
```
|
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
I'm using the OpenApiHandler with contracts. I have the following contract defined:
I'm getting the following error:
Is there something I'm doing wrong?
Beta Was this translation helpful? Give feedback.
All reactions