From 4e06ea7bdbaaa196da5c3e2a755aeefb25cf4228 Mon Sep 17 00:00:00 2001 From: xuatz Date: Mon, 19 May 2025 00:18:58 +0900 Subject: feat(api): enable ?sortOrder= for relevant resources (#1398) * feat(api): enable `?sortOrder=` for relevant resources * fix tests --- packages/open-api/lib/lists.ts | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) (limited to 'packages/open-api/lib/lists.ts') diff --git a/packages/open-api/lib/lists.ts b/packages/open-api/lib/lists.ts index ab07e425..992b96c4 100644 --- a/packages/open-api/lib/lists.ts +++ b/packages/open-api/lib/lists.ts @@ -4,6 +4,7 @@ import { } from "@asteasolutions/zod-to-openapi"; import { z } from "zod"; +import { zSortOrder } from "@karakeep/shared/types/bookmarks"; import { zBookmarkListSchema, zEditBookmarkListSchema, @@ -190,13 +191,21 @@ registry.registerPath({ registry.registerPath({ method: "get", path: "/lists/{listId}/bookmarks", - description: "Get the bookmarks in a list", - summary: "Get a bookmarks in a list", + description: "Get bookmarks in the list", + summary: "Get bookmarks in the list", tags: ["Lists"], security: [{ [BearerAuth.name]: [] }], request: { params: z.object({ listId: ListIdSchema }), - query: PaginationSchema.merge(IncludeContentSearchParamSchema), + query: z + .object({ + sortOrder: zSortOrder + .exclude(["relevance"]) + .optional() + .default(zSortOrder.Enum.desc), + }) + .merge(PaginationSchema) + .merge(IncludeContentSearchParamSchema), }, responses: { 200: { -- cgit v1.2.3-70-g09d2