fix: Schema validation errors correctly returned as 422 (#2828)

* fix: Schema validation errors correctly returned as 422
This commit is contained in:
McPizza
2024-12-03 18:12:29 +01:00
committed by GitHub
parent d3523ed1d6
commit 7728a4793b
3 changed files with 12 additions and 4 deletions
@@ -44,7 +44,7 @@ export const DefaultResponseErrorsSchema = {
401: z.object({
requestId: z.string(),
statusCode: z.literal(401),
message: z.any(),
message: z.string(),
error: z.string()
}),
403: z.object({
@@ -54,6 +54,13 @@ export const DefaultResponseErrorsSchema = {
details: z.any().optional(),
error: z.string()
}),
// Zod errors return a message of varying shapes and sizes, so z.any() is used here
422: z.object({
requestId: z.string(),
statusCode: z.literal(422),
message: z.any(),
error: z.string()
}),
500: z.object({
requestId: z.string(),
statusCode: z.literal(500),