Search results
SearchResults
Section titled “SearchResults”A 200 response with a paginated list of items matching a search term and filters. It extends Filtered with a searchInfo property that confirms the search term the server used.
searchInfo is omitted when the request had no search term. An empty or whitespace-only search value counts as no search term.
| 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 |
| filterInfo | object | The filters applied to the response items |
| searchInfo | SearchResultsInfo | The search term applied to the response items, if one was sent |
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": { "sortBy": "name", "sortOrder": "asc" }, "filterInfo": { "filters": { "lastModifiedAt": { "operator": "gte", "value": "2024-01-01T00:00:00Z" } } }, "searchInfo": { "query": "Pre-school education" }}The JSON Schema for this model.
$schema: https://json-schema.org/draft/2020-12/schema$id: SearchResults.yamltype: objectproperties: items: type: array items: {} description: Items from the current page paginationInfo: $ref: PaginatedResultsInfo.yaml description: Details about the paginated results sortInfo: $ref: SortedResultsInfo.yaml description: The sort order of the items filterInfo: type: object properties: filters: {} errors: type: array items: type: string description: Non-fatal errors that occurred during filtering required: - filters unevaluatedProperties: not: {} description: The filters applied to the response items searchInfo: $ref: SearchResultsInfo.yaml description: |- The search term applied to the response items
Omitted when the request had no search term. An empty or whitespace-only `search` value counts as no search term.required: - items - paginationInfo - sortInfo - filterInfoallOf: - $ref: Success.yamlunevaluatedProperties: not: {}description: A paginated list of items matching a searchThe TypeSpec code for this model.
...Headers.VersionResponse; ...FilteredBase<ItemsT, FilterT>;}
// ############################################################################// 200 search results response// ############################################################################
/** Details about the search term applied to the response items */@Versioning.added(CommonGrants.Versions.v0_6)model SearchResultsInfo { /** The search term used to find the response items */ @example("Pre-school education") query: string;}
/** Body properties shared by `SearchResults` and `SearchResultsT<ItemsT, FilterT>` * * @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 */@Versioning.added(CommonGrants.Versions.v0_6)model SearchResultsBase<ItemsT, FilterT> { ...FilteredBase<ItemsT, FilterT>;
/** The search term applied to the response itemsUse the SearchResultsT<ItemsT, FilterT> template to define a 200 response with a paginated list of typed items matching a search within an API operation:
import "@common-grants/core";import "@typespec/http";
using TypeSpec.Http;using CommonGrants;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 search term and filter")@postop searchTest( search?: string, filters?: TestFilter, pagination?: PaginatedBodyParams,): SearchResultsT<TestModel, TestFilter>;Changelog
Section titled “Changelog”| Version | Changes | Schema |
|---|---|---|
| 0.6.0 |
| SearchResults.yaml |
SearchResultsInfo
Section titled “SearchResultsInfo”Details about the search term applied to the response items.
| Parameter | Type | Description |
|---|---|---|
| query | string | The search term used to find the response items |
Formats
Section titled “Formats”A JSON example of this model.
{ "query": "Pre-school education"}The JSON Schema for this model.
$schema: https://json-schema.org/draft/2020-12/schema$id: SearchResultsInfo.yamltype: objectproperties: query: type: string examples: - Pre-school education description: The search term used to find the response itemsrequired: - queryunevaluatedProperties: not: {}description: Details about the search term applied to the response itemsThe TypeSpec code for this model.
* ``` */@doc("A paginated list of typed items with a typed filter")@Versioning.added(CommonGrants.Versions.v0_1)model FilteredT<ItemsT, FilterT> extends Success { // Inherit the 200 status code ...Http.OkResponse;Changelog
Section titled “Changelog”| Version | Changes | Schema |
|---|---|---|
| 0.6.0 |
| SearchResultsInfo.yaml |