Skip to content

Filtered

A 200 response with a paginated list of filtered items.

ParameterTypeDescription
statusintegerThe HTTP status code
messagestringThe message to return
itemsArrayItems from the current page
paginationInfoPaginatedResultsInfoDetails about the pagination
sortInfoSortedResultsInfoThe sort order of the items
filterInfoobjectThe filters applied to the response 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"
},
"filterInfo": {
"filters": {
"lastModifiedAt": {
"operator": "gte",
"value": "2024-01-01T00:00:00Z"
},
"status": {
"operator": "in",
"value": [
"active",
"inactive"
]
}
}
}
}

Use the FilteredT<ItemsT, FilterT> template to define a 200 response with a paginated list of filtered, 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;
}
model TestFilter extends Record<Filters.DefaultFilter> {
lastModifiedAt: Filters.DateComparisonFilter;
}
@summary("Search test models")
@doc("Get a paginated list of test models matching a filter")
@post
op searchTest(...PaginatedBodyParams): FilteredT<TestModel, TestFilter>;
Version Changes Schema
0.1.0
  • Added Filtered model
Filtered.yaml