diff --git a/packages/typebox/src/index.ts b/packages/typebox/src/index.ts index f7d0c2cafb..eaabd2b907 100644 --- a/packages/typebox/src/index.ts +++ b/packages/typebox/src/index.ts @@ -159,6 +159,8 @@ export const querySyntax = < options: ObjectOptions = { additionalProperties: false } ) => { const propertySchema = queryProperties(type, extensions) + const $or = Type.Array(propertySchema) + const $and = Type.Array(Type.Union([propertySchema, Type.Object({ $or })])) return Type.Intersect( [ @@ -169,8 +171,8 @@ export const querySyntax = < $skip: Type.Number({ minimum: 0 }), $sort: sortDefinition(type), $select: arrayOfKeys(type), - $or: Type.Array(propertySchema), - $and: Type.Array(propertySchema) + $and, + $or }, { additionalProperties: false } )