From b0dac24eea04eac84f2795c3f33e36f79e865e15 Mon Sep 17 00:00:00 2001 From: Zoe Roux Date: Fri, 15 Nov 2024 23:39:09 +0100 Subject: [PATCH] Use kind guards in registerExamples --- api/src/models/examples/index.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/api/src/models/examples/index.ts b/api/src/models/examples/index.ts index 5e59939f..2dd5b9f6 100644 --- a/api/src/models/examples/index.ts +++ b/api/src/models/examples/index.ts @@ -1,16 +1,17 @@ import type { TSchema } from "elysia"; +import { KindGuard } from "@sinclair/typebox" export const registerExamples = ( schema: T, ...examples: (T["static"] | undefined)[] ) => { - if ("anyOf" in schema) { + if (KindGuard.IsUnion(schema)) { for (const union of schema.anyOf) { registerExamples(union, ...examples); } return; } - if ("allOf" in schema) { + if (KindGuard.IsIntersect(schema)) { for (const intersec of schema.allOf) { registerExamples(intersec, ...examples); }