Skip to content

Paginated

A 200 response with a paginated list of items.

Parameter Type Description
status integer The HTTP status code
message string The message to return
items array Items from the current page
paginationInfo PaginatedResultsInfo Details about the pagination

A JSON example of this model.

{
"status": 200,
"message": "Success",
"items": [
{
"id": "123",
"name": "Test 1"
},
{
"id": "124",
"name": "Test 2"
}
],
"paginationInfo": {
"page": 1,
"pageSize": 10,
"totalItems": 25,
"totalPages": 3
}
}

From v0.6.0, the typed PaginatedT<T> response carries the version response headers declared in Headers.VersionResponse: CG-Version-Served, which reports the full protocol version the response was served in, and the optional Vary, Deprecation, Sunset and Link headers. See Versioning and the Versions section of the specification.

Use the PaginatedT<T> template to define a 200 response with a paginated list of typed items within an API operation:

import "@common-grants/core";
import "@typespec/http";
using TypeSpec.Http;
using CommonGrants.Pagination;
using CommonGrants.Responses;
model TestModel {
id: string;
name: string;
}
@summary("List test models")
@doc("Get a paginated list of test models")
@get
op listTest(...PaginatedQueryParams): PaginatedT<TestModel>;
VersionChangesSchema
0.1.0
  • Added Paginated model
Paginated.yaml