| import "@typespec/http"; | |
| import "@typespec/rest"; | |
| import "@typespec/openapi3"; | |
| using TypeSpec.Http; | |
| namespace OpenMeter; | |
| /** | |
| * Pagination query params | |
| */ | |
| model QueryPagination { | |
| /** | |
| * Page index. | |
| * | |
| * Default is 1. | |
| */ | |
| page?: integer = 1; | |
| /** | |
| * The maximum number of items per page. | |
| * | |
| * Default is 100. | |
| */ | |
| pageSize?: integer = 100; | |
| } | |
| /** | |
| * Limit and offset query params | |
| */ | |
| model QueryLimitOffset { | |
| /** | |
| * Number of items to skip. | |
| * | |
| * Default is 0. | |
| */ | |
| offset?: integer = 0; | |
| /** | |
| * Number of items to return. | |
| * | |
| * Default is 100. | |
| */ | |
| limit?: integer = 100; | |
| } | |
| /** | |
| * Ordering query params | |
| */ | |
| model QueryOrdering<T> { | |
| /** | |
| * The order direction. | |
| */ | |
| order?: SortOrder = SortOrder.ASC; | |
| /** | |
| * The order by field. | |
| * | |
| * @TODO Default values cannot be passed as generics in typespec, | |
| * even though the docs say so: | |
| * https://typespec.io/docs/language-basics/templates | |
| */ | |
| orderBy?: T; | |
| } | |
| /** | |
| * The order direction. | |
| */ | |
| enum SortOrder { | |
| #suppress "@openmeter/api-spec-legacy/casing" "Use existing values" | |
| ASC: "ASC", | |
| #suppress "@openmeter/api-spec-legacy/casing" "Use existing values" | |
| DESC: "DESC", | |
| } | |
| /** | |
| * Paginated response | |
| */ | |
| model PaginatedResponse<T> { | |
| /** | |
| * The total number of items. | |
| */ | |
| totalCount: integer; | |
| /** | |
| * The page index. | |
| */ | |
| page: integer; | |
| /** | |
| * The maximum number of items per page. | |
| */ | |
| pageSize: integer; | |
| /** | |
| * The items in the current page. | |
| */ | |
| items: T[]; | |
| } | |
| /** | |
| * Paginated cursor query parameters. | |
| */ | |
| model QueryCursorPagination { | |
| /** | |
| * The cursor after which to start the pagination. | |
| */ | |
| cursor?: string; | |
| /** | |
| * The limit of the pagination. | |
| */ | |
| limit?: integer = 100; | |
| } | |
| /** | |
| * A response for cursor pagination. | |
| */ | |
| model CursorPaginatedResponse<T> { | |
| /** | |
| * The items in the response. | |
| */ | |
| items: T[]; | |
| /** | |
| * The cursor of the last item in the list. | |
| */ | |
| nextCursor?: string; | |
| } | |