-
-
Notifications
You must be signed in to change notification settings - Fork 4
Closed
Description
Hey there, this is a great library and I'm excited to use it. I created a PUT route, and when I tested with invalid data, I didn't get any output from my curl command. It gives a 400, but I would expect to receive validation error information along with it.
Indeed, the validation error comes up in the console, but I need it to be part of the response. Validation error:
[
{
code: 'invalid_type',
expected: 'string',
received: 'undefined',
path: [ 'name' ],
message: 'Required'
}
]
Simplified example:
import defineRoute from "@omer-x/next-openapi-route-handler";
import z from "zod";
export const { PUT } = defineRoute({
operationId: "putThing",
method: "PUT",
summary: "Create a new thing",
description: "Create a new thing with the given details",
tags: ["Things"],
requestBody: z.object({
name: z.string(),
}),
action: async () => {
return Response.json({ id: "123" });
},
responses: {
200: {
description: "Thing retrieved successfully",
content: z.object({
id: z.string(),
}),
},
},
});
Also, when the route fails, I get a 500 but the error is not displayed in the console. If I use a vanilla nextjs route, the error shows up.
Metadata
Metadata
Assignees
Labels
No labels