Sorted
Sorted
Section titled “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 |
Formats
Section titled “Formats”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" }}The JSON Schema for this model.
$schema: https://json-schema.org/draft/2020-12/schema$id: Sorted.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: PaginatedResultsInfo.yaml sortInfo: $ref: SortedResultsInfo.yamlrequired: - status - message - items - paginationInfo - sortInfoThe TypeSpec code for this model.
model Sorted<T> { // Inherit the properties of the Paginated response ...Paginated<T>;
/** The sort order of the items */ sortInfo: Sorting.SortedResultsInfo;}The Python code for this model.
class Sorted(Paginated[ItemsT], Generic[ItemsT]): """A paginated list of items with a sort order."""
sort_info: SortedResultsInfo = Field( ..., description="The sort order of the items", alias="sortInfo", )
model_config = {"populate_by_name": True}The TypeScript code for this model.
export const SortedSchema = <T extends z.ZodTypeAny>(itemsSchema: T) => PaginatedSchema(itemsSchema).extend({ /** The sort order of the items */ sortInfo: SortedResultsInfoSchema, });Changelog
Section titled “Changelog”| Version | Changes | Schema |
|---|---|---|
| 0.1.0 |
| Sorted.yaml |
Here’s an example of how to use the Sorted response within a 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")@getop listTest(...PaginatedQueryParams): Sorted<TestModel>;