Copy
{
"$schema": "http://json-schema.org/draft-07/schema#",
"title": "SearchFilter",
"type": "object",
"properties": {
"query": {
"type": "string"
},
"filters": {
"type": "object",
"properties": {
"category": {
"type": "string"
},
"minPrice": {
"type": "integer"
},
"maxPrice": {
"type": "integer"
},
"inStock": {
"type": "boolean"
}
},
"required": [
"category",
"minPrice",
"maxPrice",
"inStock"
],
"additionalProperties": false
},
"facets": {
"type": "object",
"properties": {
"category": {
"type": "array",
"items": {
"type": "object",
"properties": {
"value": {
"type": "string"
},
"count": {
"type": "integer"
}
},
"required": [
"value",
"count"
],
"additionalProperties": false
}
},
"brand": {
"type": "array",
"items": {
"type": "object",
"properties": {
"value": {
"type": "string"
},
"count": {
"type": "integer"
}
},
"required": [
"value",
"count"
],
"additionalProperties": false
}
}
},
"required": [
"category",
"brand"
],
"additionalProperties": false
},
"items": {
"type": "array",
"items": {
"type": "object",
"properties": {
"id": {
"type": "integer"
},
"title": {
"type": "string"
},
"price": {
"type": "integer"
},
"category": {
"type": "string"
},
"brand": {
"type": "string"
}
},
"required": [
"id",
"title",
"price",
"category",
"brand"
],
"additionalProperties": false
}
},
"total": {
"type": "integer"
},
"skip": {
"type": "integer"
},
"limit": {
"type": "integer"
}
},
"required": [
"query",
"filters",
"facets",
"items",
"total",
"skip",
"limit"
],
"additionalProperties": false
}
Copy
import { z } from 'zod';
export const SearchFilterSchema = z.object({
query: z.string(),
filters: z.object({
category: z.string(),
minPrice: z.number(),
maxPrice: z.number(),
inStock: z.boolean()
}),
facets: z.object({
category: z.array(z.object({
value: z.string(),
count: z.number()
})),
brand: z.array(z.object({
value: z.string(),
count: z.number()
}))
}),
items: z.array(z.object({
id: z.number(),
title: z.string(),
price: z.number(),
category: z.string(),
brand: z.string()
})),
total: z.number(),
skip: z.number(),
limit: z.number()
});
export type SearchFilter = z.infer<typeof SearchFilterSchema>;