Skip to content

Commit 9d8832f

Browse files
authored
Merge pull request #476 from talktosam2003/navin347
offset pagination
2 parents 1a55e8e + dc8c6e3 commit 9d8832f

7 files changed

Lines changed: 919 additions & 627 deletions

File tree

docs/swagger.yaml

Lines changed: 72 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2270,7 +2270,17 @@ paths:
22702270
$ref: '#/components/schemas/ErrorResponse'
22712271
get:
22722272
summary: List users
2273-
description: Returns a paginated list of users. Requires authentication and role (ADMIN/MANAGER/SUPER_ADMIN).
2273+
description: >-
2274+
Returns a paginated list of users within the caller's organization.
2275+
Requires authentication and ADMIN / MANAGER / SUPER_ADMIN role.
2276+
2277+
**Pagination modes** (mutually exclusive — sending both `cursor` and `page` is a 400):
2278+
2279+
* **Cursor mode** (`cursor` + `limit`) → `meta: { nextCursor, hasMore }`
2280+
* **Offset mode** (`page` + `limit`) → `meta: { page, limit, total }`
2281+
2282+
**Filters** (`search`, `role`) work in both modes.
2283+
Unknown query params are silently ignored and do **not** cause a 400.
22742284
security:
22752285
- bearerAuth: []
22762286
parameters:
@@ -2281,12 +2291,32 @@ paths:
22812291
minimum: 1
22822292
maximum: 100
22832293
default: 20
2284-
description: Maximum number of users to return per page
2294+
description: Maximum number of users per page
22852295
- in: query
22862296
name: cursor
22872297
schema:
22882298
type: string
2289-
description: Cursor for the next page (ObjectId of the last user from the previous page)
2299+
description: >-
2300+
Cursor for the next page in cursor mode (ObjectId of the last user
2301+
from the previous page). Mutually exclusive with `page`.
2302+
- in: query
2303+
name: page
2304+
schema:
2305+
type: integer
2306+
minimum: 1
2307+
description: >-
2308+
1-based page number for offset pagination. Mutually exclusive with `cursor`.
2309+
- in: query
2310+
name: search
2311+
schema:
2312+
type: string
2313+
description: Case-insensitive substring search on `name` and `email`.
2314+
- in: query
2315+
name: role
2316+
schema:
2317+
type: string
2318+
enum: [SUPER_ADMIN, ADMIN, MANAGER, DRIVER, VIEWER, CUSTOMER]
2319+
description: Filter results to users with this exact role.
22902320
responses:
22912321
'200':
22922322
description: Users retrieved
@@ -2314,16 +2344,46 @@ paths:
23142344
type: string
23152345
organizationId:
23162346
type: string
2347+
createdAt:
2348+
type: string
2349+
format: date-time
23172350
meta:
2318-
type: object
2319-
properties:
2320-
total:
2321-
type: integer
2322-
hasMore:
2323-
type: boolean
2324-
nextCursor:
2325-
type: string
2326-
nullable: true
2351+
oneOf:
2352+
- description: Cursor mode meta
2353+
type: object
2354+
properties:
2355+
nextCursor:
2356+
type: string
2357+
nullable: true
2358+
hasMore:
2359+
type: boolean
2360+
- description: Offset mode meta
2361+
type: object
2362+
properties:
2363+
page:
2364+
type: integer
2365+
limit:
2366+
type: integer
2367+
total:
2368+
type: integer
2369+
'400':
2370+
description: Validation error (e.g. cursor and page both provided)
2371+
content:
2372+
application/json:
2373+
schema:
2374+
$ref: '#/components/schemas/ErrorResponse'
2375+
'401':
2376+
description: Missing or invalid authorization token
2377+
content:
2378+
application/json:
2379+
schema:
2380+
$ref: '#/components/schemas/ErrorResponse'
2381+
'403':
2382+
description: Forbidden – insufficient role (must be ADMIN / MANAGER / SUPER_ADMIN)
2383+
content:
2384+
application/json:
2385+
schema:
2386+
$ref: '#/components/schemas/ErrorResponse'
23272387
/api/users/team:
23282388
post:
23292389
summary: Create a user as a team member (admin only)

0 commit comments

Comments
 (0)