20 lines
541 B
TypeScript
20 lines
541 B
TypeScript
![]() |
import type { SwaggerMessage } from "@/types/swagger.type";
|
||
|
|
||
|
const STATUS_CODE_MAP: Record<number, string> = {
|
||
|
400: "Bad Request",
|
||
|
401: "Unauthorized",
|
||
|
404: "Not Found",
|
||
|
409: "Conflict",
|
||
|
500: "Internal Server Error",
|
||
|
};
|
||
|
|
||
|
export const swaggerError = (code: number, message: string): SwaggerMessage => ({
|
||
|
type: "object",
|
||
|
properties: {
|
||
|
statusCode: { type: "integer" },
|
||
|
error: { type: "string" },
|
||
|
message: { type: "string" },
|
||
|
},
|
||
|
examples: [{ statusCode: code, error: STATUS_CODE_MAP[code], message: message }],
|
||
|
});
|