Skip to content

Instantly share code, notes, and snippets.

@ikenna
Last active February 5, 2024 13:14
Show Gist options
  • Save ikenna/22fcd79c76f0490326d2c61e2268be91 to your computer and use it in GitHub Desktop.
Save ikenna/22fcd79c76f0490326d2c61e2268be91 to your computer and use it in GitHub Desktop.
Cursor based pagination
openapi: 3.0.0
info:
title: Cursor Pagination API
version: 1.0.0
paths:
/items:
get:
summary: Get a list of items
parameters:
- name: cursor
in: query
description: Cursor for pagination
required: false
schema:
type: string
maxLength: 50
- name: limit
in: query
description: Limit the number of items returned
required: false
schema:
type: integer
format: int32
responses:
'200':
description: A list of items
content:
application/json:
schema:
type: object
properties:
pagination:
type: object
properties:
first:
type: string
description: The cursor for the first page of results
example: "cursor1"
maxLength: 50
last:
type: string
description: The cursor for the last page of results
example: "cursor10"
maxLength: 50
prev:
type: string
description: The cursor for the previous page of results
example: "cursor3"
maxLength: 50
self:
type: string
description: The cursor for the current page of results
example: "cursor4"
maxLength: 50
items:
type: array
items:
type: object
properties:
id:
type: integer
format: int64
name:
type: string
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment