Skip to content

Sorted

A 200 response with a paginated list of sorted 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
sortInfo SortedResultsInfo The sort order of the items

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
},
"sortInfo": {
"field": "name",
"direction": "asc"
}
}

Use the SortedT<T> template to define a 200 response with a paginated list of sorted, 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): SortedT<TestModel>;
VersionChangesSchema
0.1.0
  • Added Sorted model
Sorted.yaml