@@ -5,50 +5,37 @@ extendZodWithOpenApi(z);
55
66export const QuerySchema = z
77 . object ( {
8- offset : z . number ( ) . openapi ( {
8+ offset : z . coerce . number ( ) . int ( ) . nonnegative ( ) . default ( 0 ) . openapi ( {
99 example : 0 ,
1010 description : 'Offset for pagination' ,
1111 } ) ,
12- limit : z . number ( ) . max ( 500 ) . openapi ( {
13- example : 10 ,
12+ limit : z . coerce . number ( ) . int ( ) . nonnegative ( ) . max ( 500 ) . default ( 25 ) . openapi ( {
13+ example : 25 ,
1414 description : 'Limit for pagination' ,
1515 } ) ,
16- sort : z
17- . object ( {
18- field : z . string ( ) . openapi ( {
19- example : 'name' ,
20- description : 'Field to sort by' ,
21- } ) ,
22- order : z . enum ( [ 'asc' , 'desc' ] ) . openapi ( {
23- example : 'asc' ,
24- description : 'Order of sorting' ,
25- } ) ,
26- } )
27- . optional ( )
28- . openapi ( {
29- description : 'Sorting options' ,
30- } ) ,
31- filter : z
32- . object ( {
33- field : z . string ( ) . openapi ( {
34- example : 'status' ,
35- description : 'Field to filter by' ,
36- } ) ,
37- comparator : z
38- . enum ( [ 'equal' , 'not_equal' , 'greater_than' , 'less_than' , 'contains' , 'starts_with' , 'ends_with' ] )
39- . openapi ( {
40- example : 'equal' ,
41- description : 'Comparator for filtering' ,
42- } ) ,
43- value : z . any ( ) . openapi ( {
44- example : 'active' ,
45- description : 'Value to filter by' ,
46- } ) ,
47- } )
16+ sort : z . string ( ) . optional ( ) . openapi ( {
17+ example : 'createdAt' ,
18+ description : 'Field to sort by, e.g., "createdAt" or "name"' ,
19+ } ) ,
20+ orderBy : z . enum ( [ 'ASC' , 'DESC' ] ) . optional ( ) . openapi ( {
21+ example : 'ASC' ,
22+ description : 'Order of sorting, either "ASC" or "DESC"' ,
23+ } ) ,
24+ filterField : z . string ( ) . optional ( ) . openapi ( {
25+ example : 'status' ,
26+ description : 'Field to filter by, e.g., "status" or "type"' ,
27+ } ) ,
28+ filterComparator : z
29+ . enum ( [ 'equal' , 'not_equal' , 'greater_than' , 'less_than' , 'contains' , 'starts_with' , 'ends_with' ] )
4830 . optional ( )
4931 . openapi ( {
50- description : 'Filtering options' ,
32+ example : 'equal' ,
33+ description : 'Comparator for filtering, e.g., "equal" or "contains"' ,
5134 } ) ,
35+ filterValue : z . any ( ) . optional ( ) . openapi ( {
36+ example : 'active' ,
37+ description : 'Value to filter by, e.g., "active" or "error"' ,
38+ } ) ,
5239 } )
5340 . openapi ( { ref : 'Query' } ) ;
5441
0 commit comments