diff --git a/projects/api/src/contracts/_internal/z.ts b/projects/api/src/contracts/_internal/z.ts index 175a009..d061f7e 100644 --- a/projects/api/src/contracts/_internal/z.ts +++ b/projects/api/src/contracts/_internal/z.ts @@ -19,6 +19,18 @@ export function float(schema: z.ZodNumber) { /** * Helper function to mark a number schema as a double in OpenAPI metadata */ +export function double(schema: z.ZodNumber) { + // Use type assertion to access the openapi method added by extendZodWithOpenApi + return (schema as z.ZodNumber & { openapi: (meta: unknown) => z.ZodNumber }) + .openapi({ + type: 'number', + format: 'double', + }); +} + +/** + * Helper function to mark a number schema as an int64 in OpenAPI metadata + */ export function int64(schema: z.ZodNumber) { // Use type assertion to access the openapi method added by extendZodWithOpenApi return (schema as z.ZodNumber & { openapi: (meta: unknown) => z.ZodNumber }) diff --git a/projects/api/src/contracts/search/schema/response/searchListResponseSchema.ts b/projects/api/src/contracts/search/schema/response/searchListResponseSchema.ts index 1851a8a..7b356cc 100644 --- a/projects/api/src/contracts/search/schema/response/searchListResponseSchema.ts +++ b/projects/api/src/contracts/search/schema/response/searchListResponseSchema.ts @@ -1,9 +1,9 @@ -import { int64, z } from '../../../_internal/z.ts'; +import { double, z } from '../../../_internal/z.ts'; import { listResponseSchema } from '../../../models/index.ts'; /** Zod schema for the search list response. */ export const searchListResponseSchema = z.object({ - score: int64(z.number().int()), + score: double(z.number()), type: z.literal('list'), list: listResponseSchema.nullish(), }); diff --git a/projects/api/src/contracts/search/schema/response/searchMovieResponseSchema.ts b/projects/api/src/contracts/search/schema/response/searchMovieResponseSchema.ts index b0655ed..6ba7d1c 100644 --- a/projects/api/src/contracts/search/schema/response/searchMovieResponseSchema.ts +++ b/projects/api/src/contracts/search/schema/response/searchMovieResponseSchema.ts @@ -1,9 +1,9 @@ import { movieResponseSchema } from '../../../_internal/response/movieResponseSchema.ts'; -import { int64, z } from '../../../_internal/z.ts'; +import { double, z } from '../../../_internal/z.ts'; /** Zod schema for the search movie response. */ export const searchMovieResponseSchema = z.object({ - score: int64(z.number().int()), + score: double(z.number()), type: z.literal('movie'), movie: movieResponseSchema.nullish(), }); diff --git a/projects/api/src/contracts/search/schema/response/searchPersonResponseSchema.ts b/projects/api/src/contracts/search/schema/response/searchPersonResponseSchema.ts index bcc8d5f..1b363df 100644 --- a/projects/api/src/contracts/search/schema/response/searchPersonResponseSchema.ts +++ b/projects/api/src/contracts/search/schema/response/searchPersonResponseSchema.ts @@ -1,9 +1,9 @@ -import { int64, z } from '../../../_internal/z.ts'; +import { double, z } from '../../../_internal/z.ts'; import { personResponseSchema } from '../../../people/schema/response/personResponseSchema.ts'; /** Zod schema for the search person response. */ export const searchPersonResponseSchema = z.object({ - score: int64(z.number().int()), + score: double(z.number()), type: z.literal('person'), person: personResponseSchema.nullish(), }); diff --git a/projects/api/src/contracts/search/schema/response/searchShowResponseSchema.ts b/projects/api/src/contracts/search/schema/response/searchShowResponseSchema.ts index 8365c2d..d739eea 100644 --- a/projects/api/src/contracts/search/schema/response/searchShowResponseSchema.ts +++ b/projects/api/src/contracts/search/schema/response/searchShowResponseSchema.ts @@ -1,9 +1,9 @@ import { showResponseSchema } from '../../../_internal/response/showResponseSchema.ts'; -import { int64, z } from '../../../_internal/z.ts'; +import { double, z } from '../../../_internal/z.ts'; /** Zod schema for the search show response. */ export const searchShowResponseSchema = z.object({ - score: int64(z.number().int()), + score: double(z.number()), type: z.literal('show'), show: showResponseSchema.nullish(), });