Filtered
A 200 response with a paginated list of filtered items.
Parameter | Type | Description |
---|---|---|
status | integer | The HTTP status code |
message | string | The message to return |
items | Array | Items from the current page |
paginationInfo | PaginationInfo | Details about the pagination |
sortInfo | SortInfo | The sort order of the items |
filterInfo | object | The filters applied to the response items |
Formats
Section titled “Formats”An example filtered response:
{ "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": { "lastModifiedAt": { "operator": "gte", "value": "2024-01-01T00:00:00Z" } }}
The JSON schema for this model is:
$schema: https://json-schema.org/draft/2020-12/schema$id: Filtered.yamltype: objectproperties: status: type: integer minimum: 200 default: 200 description: The HTTP status code message: type: string default: "Success" description: The message to return items: type: array description: Items from the current page paginationInfo: $ref: "#/components/schemas/CommonGrants.Pagination.PaginationInfo" sortInfo: $ref: "#/components/schemas/CommonGrants.Sorting.SortInfo" filterInfo: type: object description: The filters applied to the response itemsrequired: - status - message - items - paginationInfo - sortInfo - filterInfo
The TypeSpec code for this model is:
/** A paginated list of items with a filter * * @template ItemsT The schema for the value of the `"items"` property in this response * @template FilterT The schema for the value of the `"filter"` property in this response */model Filtered<ItemsT, FilterT> extends Success { // Inherit the properties of the Sorted response ...Sorted<ItemsT>;
/** The filters applied to the response items */ filterInfo: FilterT;}
The OpenAPI specification for this model is:
components: schemas: CommonGrants.Responses.Filtered: type: object properties: status: type: integer minimum: 200 default: 200 description: The HTTP status code message: type: string default: "Success" description: The message to return items: type: array description: Items from the current page paginationInfo: $ref: "#/components/schemas/CommonGrants.Pagination.PaginationInfo" sortInfo: $ref: "#/components/schemas/CommonGrants.Sorting.SortInfo" filterInfo: type: object description: The filters applied to the response items required: - status - message - items - paginationInfo - sortInfo - filterInfo
import "@common-grants/core";import "@typespec/http";
using TypeSpec.Http;using CommonGrants.Pagination;using CommonGrants.Responses;using CommonGrants.Filters;
model TestModel { id: string; name: string;}
model TestFilter { title: StringComparisonFilter;}
@summary("Get test")@doc("Get a test model")@getop getTest( filters: TestFilter, pagination: PaginatedBodyParams,): Filtered<TestModel, TestFilter>;