-
-
Notifications
You must be signed in to change notification settings - Fork 4
Closed
Labels
bugSomething isn't workingSomething isn't working
Description
export const { PUT } = defineRoute({
operationId: 'updateOrder',
method: 'PUT',
summary: 'Update order',
description:
'Update order text fields. To update order images use /api/orders/images',
tags: ['Orders'],
requestBody: UpdatedOrderFieldsApiDTO,
action: async ({}) => {
// return handleServerActionResponseInApiRoute(
// await updateOrderHandler(body, true),
// 200
// );
return Response.json(null, { status: 501 });
},
responses: {
201: { description: 'Order fields updated successfully' },
400: {
description:
'Invalid request params or order cannot be updated for the reason described in the error message',
content: AaaApiErrorDTO,
},
403: {
description: 'No access to selected club location',
},
501: { description: 'Method not implemented' },
},
handleErrors: (errorType, issues) => {
return apiRouteErrorHandler(errorType, issues);
},
});
export const AaaApiErrorDTO = z.object({
errorMessage: z.string(),
validationErrors: ValidationErrorDTO.array().optional(),
});
Providing description and content for 400 status will not work, because library handles Bad Requests differently, ignoring content and description:
export function addBadRequest(queryParams?: unknown, requestBody?: unknown) {
if (!queryParams && !requestBody) return undefined;
return { description: "Bad Request" } as ResponseObject;
}
In case of 400, my endpoint returns an explanation why request failed. I would want to have my Error schema in OpenAPI json docs as well, but I can't due to library design. Why was it designed like that?

Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working