fix: OpenAPI spec not generating properly
Summary: Test Plan:
This commit is contained in:
@@ -2,11 +2,13 @@ import { type ZodSchema, z } from "zod";
|
||||
|
||||
export const SuccessResponse = { success: true } as const;
|
||||
export const SuccessResponseSchema = <T extends ZodSchema>(schema?: T) => {
|
||||
const success = z.literal(true).openapi({ type: "boolean" });
|
||||
|
||||
if (!schema) {
|
||||
return z.object({ success: z.literal(true) });
|
||||
return z.object({ success });
|
||||
}
|
||||
|
||||
return z.object({ success: z.literal(true), result: schema });
|
||||
return z.object({ success, result: schema });
|
||||
};
|
||||
|
||||
export const PaginatedResponseSchema = <T extends ZodSchema>(schema: T) => {
|
||||
@@ -18,9 +20,12 @@ export const PaginatedResponseSchema = <T extends ZodSchema>(schema: T) => {
|
||||
};
|
||||
|
||||
export const ErrorResponseSchema = z.object({
|
||||
success: z.literal(false),
|
||||
success: z.literal(false).openapi({ type: "boolean" }),
|
||||
});
|
||||
|
||||
export const AniListIdSchema = z
|
||||
.number({ coerce: true })
|
||||
.openapi({ type: "integer" });
|
||||
export const NullableNumberSchema = z.number().int().nullable();
|
||||
|
||||
export const AniListIdSchema = z.number().int().openapi({ format: "int64" });
|
||||
export const AniListIdQuerySchema = z
|
||||
.string()
|
||||
.openapi({ type: "integer", format: "int64" });
|
||||
|
||||
Reference in New Issue
Block a user