aboutsummaryrefslogtreecommitdiffstats
path: root/packages/open-api/lib
diff options
context:
space:
mode:
Diffstat (limited to 'packages/open-api/lib')
-rw-r--r--packages/open-api/lib/bookmarks.ts89
-rw-r--r--packages/open-api/lib/errors.ts6
-rw-r--r--packages/open-api/lib/highlights.ts41
-rw-r--r--packages/open-api/lib/lists.ts73
-rw-r--r--packages/open-api/lib/tags.ts33
5 files changed, 242 insertions, 0 deletions
diff --git a/packages/open-api/lib/bookmarks.ts b/packages/open-api/lib/bookmarks.ts
index b45d6350..51c67369 100644
--- a/packages/open-api/lib/bookmarks.ts
+++ b/packages/open-api/lib/bookmarks.ts
@@ -13,6 +13,7 @@ import {
} from "@karakeep/shared/types/bookmarks";
import { BearerAuth } from "./common";
+import { ErrorSchema } from "./errors";
import { HighlightSchema } from "./highlights";
import {
BookmarkSchema,
@@ -125,6 +126,14 @@ registry.registerPath({
},
},
},
+ 400: {
+ description: "Bad request",
+ content: {
+ "application/json": {
+ schema: ErrorSchema,
+ },
+ },
+ },
},
});
registry.registerPath({
@@ -146,6 +155,14 @@ registry.registerPath({
},
},
},
+ 404: {
+ description: "Bookmark not found",
+ content: {
+ "application/json": {
+ schema: ErrorSchema,
+ },
+ },
+ },
},
});
@@ -163,6 +180,14 @@ registry.registerPath({
204: {
description: "No content - the bookmark was deleted",
},
+ 404: {
+ description: "Bookmark not found",
+ content: {
+ "application/json": {
+ schema: ErrorSchema,
+ },
+ },
+ },
},
});
@@ -194,6 +219,14 @@ registry.registerPath({
},
},
},
+ 404: {
+ description: "Bookmark not found",
+ content: {
+ "application/json": {
+ schema: ErrorSchema,
+ },
+ },
+ },
},
});
@@ -217,6 +250,14 @@ registry.registerPath({
},
},
},
+ 404: {
+ description: "Bookmark not found",
+ content: {
+ "application/json": {
+ schema: ErrorSchema,
+ },
+ },
+ },
},
});
@@ -247,6 +288,14 @@ registry.registerPath({
},
},
},
+ 404: {
+ description: "Bookmark not found",
+ content: {
+ "application/json": {
+ schema: ErrorSchema,
+ },
+ },
+ },
},
});
@@ -277,6 +326,14 @@ registry.registerPath({
},
},
},
+ 404: {
+ description: "Bookmark not found",
+ content: {
+ "application/json": {
+ schema: ErrorSchema,
+ },
+ },
+ },
},
});
@@ -299,6 +356,14 @@ registry.registerPath({
},
},
},
+ 404: {
+ description: "Bookmark not found",
+ content: {
+ "application/json": {
+ schema: ErrorSchema,
+ },
+ },
+ },
},
});
@@ -329,6 +394,14 @@ registry.registerPath({
},
},
},
+ 404: {
+ description: "Bookmark not found",
+ content: {
+ "application/json": {
+ schema: ErrorSchema,
+ },
+ },
+ },
},
});
@@ -359,6 +432,14 @@ registry.registerPath({
204: {
description: "No content - asset was replaced successfully",
},
+ 404: {
+ description: "Bookmark not found",
+ content: {
+ "application/json": {
+ schema: ErrorSchema,
+ },
+ },
+ },
},
});
@@ -379,5 +460,13 @@ registry.registerPath({
204: {
description: "No content - asset was detached successfully",
},
+ 404: {
+ description: "Bookmark not found",
+ content: {
+ "application/json": {
+ schema: ErrorSchema,
+ },
+ },
+ },
},
});
diff --git a/packages/open-api/lib/errors.ts b/packages/open-api/lib/errors.ts
new file mode 100644
index 00000000..326e0e9a
--- /dev/null
+++ b/packages/open-api/lib/errors.ts
@@ -0,0 +1,6 @@
+import { z } from "zod";
+
+export const ErrorSchema = z.object({
+ code: z.string(),
+ message: z.string(),
+});
diff --git a/packages/open-api/lib/highlights.ts b/packages/open-api/lib/highlights.ts
index 2e4ec2d1..6eb1970e 100644
--- a/packages/open-api/lib/highlights.ts
+++ b/packages/open-api/lib/highlights.ts
@@ -11,6 +11,7 @@ import {
} from "@karakeep/shared/types/highlights";
import { BearerAuth } from "./common";
+import { ErrorSchema } from "./errors";
import { PaginationSchema } from "./pagination";
export const registry = new OpenAPIRegistry();
@@ -84,6 +85,22 @@ registry.registerPath({
},
},
},
+ 400: {
+ description: "Bad highlight request",
+ content: {
+ "application/json": {
+ schema: ErrorSchema,
+ },
+ },
+ },
+ 404: {
+ description: "Bookmark not found",
+ content: {
+ "application/json": {
+ schema: ErrorSchema,
+ },
+ },
+ },
},
});
registry.registerPath({
@@ -105,6 +122,14 @@ registry.registerPath({
},
},
},
+ 404: {
+ description: "Highlight not found",
+ content: {
+ "application/json": {
+ schema: ErrorSchema,
+ },
+ },
+ },
},
});
@@ -127,6 +152,14 @@ registry.registerPath({
},
},
},
+ 404: {
+ description: "Highlight not found",
+ content: {
+ "application/json": {
+ schema: ErrorSchema,
+ },
+ },
+ },
},
});
@@ -158,5 +191,13 @@ registry.registerPath({
},
},
},
+ 404: {
+ description: "Highlight not found",
+ content: {
+ "application/json": {
+ schema: ErrorSchema,
+ },
+ },
+ },
},
});
diff --git a/packages/open-api/lib/lists.ts b/packages/open-api/lib/lists.ts
index c66acef4..f2c0d954 100644
--- a/packages/open-api/lib/lists.ts
+++ b/packages/open-api/lib/lists.ts
@@ -12,6 +12,7 @@ import {
import { BookmarkIdSchema } from "./bookmarks";
import { BearerAuth } from "./common";
+import { ErrorSchema } from "./errors";
import { PaginatedBookmarksSchema, PaginationSchema } from "./pagination";
export const registry = new OpenAPIRegistry();
@@ -78,6 +79,14 @@ registry.registerPath({
},
},
},
+ 400: {
+ description: "Bad request",
+ content: {
+ "application/json": {
+ schema: ErrorSchema,
+ },
+ },
+ },
},
});
registry.registerPath({
@@ -99,6 +108,14 @@ registry.registerPath({
},
},
},
+ 404: {
+ description: "List not found",
+ content: {
+ "application/json": {
+ schema: ErrorSchema,
+ },
+ },
+ },
},
});
@@ -116,6 +133,14 @@ registry.registerPath({
204: {
description: "No content - the bookmark was deleted",
},
+ 404: {
+ description: "List not found",
+ content: {
+ "application/json": {
+ schema: ErrorSchema,
+ },
+ },
+ },
},
});
@@ -147,6 +172,14 @@ registry.registerPath({
},
},
},
+ 404: {
+ description: "List not found",
+ content: {
+ "application/json": {
+ schema: ErrorSchema,
+ },
+ },
+ },
},
});
@@ -170,6 +203,14 @@ registry.registerPath({
},
},
},
+ 404: {
+ description: "List not found",
+ content: {
+ "application/json": {
+ schema: ErrorSchema,
+ },
+ },
+ },
},
});
@@ -187,6 +228,22 @@ registry.registerPath({
204: {
description: "No content - the bookmark was added",
},
+ 400: {
+ description: "Bookmark already in list",
+ content: {
+ "application/json": {
+ schema: ErrorSchema,
+ },
+ },
+ },
+ 404: {
+ description: "List or bookmark not found",
+ content: {
+ "application/json": {
+ schema: ErrorSchema,
+ },
+ },
+ },
},
});
@@ -204,5 +261,21 @@ registry.registerPath({
204: {
description: "No content - the bookmark was added",
},
+ 400: {
+ description: "Bookmark already not in list",
+ content: {
+ "application/json": {
+ schema: ErrorSchema,
+ },
+ },
+ },
+ 404: {
+ description: "List or bookmark not found",
+ content: {
+ "application/json": {
+ schema: ErrorSchema,
+ },
+ },
+ },
},
});
diff --git a/packages/open-api/lib/tags.ts b/packages/open-api/lib/tags.ts
index e7e6561d..86353924 100644
--- a/packages/open-api/lib/tags.ts
+++ b/packages/open-api/lib/tags.ts
@@ -10,6 +10,7 @@ import {
} from "@karakeep/shared/types/tags";
import { BearerAuth } from "./common";
+import { ErrorSchema } from "./errors";
import { PaginatedBookmarksSchema, PaginationSchema } from "./pagination";
export const registry = new OpenAPIRegistry();
@@ -69,6 +70,14 @@ registry.registerPath({
},
},
},
+ 404: {
+ description: "Tag not found",
+ content: {
+ "application/json": {
+ schema: ErrorSchema,
+ },
+ },
+ },
},
});
@@ -86,6 +95,14 @@ registry.registerPath({
204: {
description: "No content - the bookmark was deleted",
},
+ 404: {
+ description: "Tag not found",
+ content: {
+ "application/json": {
+ schema: ErrorSchema,
+ },
+ },
+ },
},
});
@@ -117,6 +134,14 @@ registry.registerPath({
},
},
},
+ 404: {
+ description: "Tag not found",
+ content: {
+ "application/json": {
+ schema: ErrorSchema,
+ },
+ },
+ },
},
});
@@ -140,5 +165,13 @@ registry.registerPath({
},
},
},
+ 404: {
+ description: "Tag not found",
+ content: {
+ "application/json": {
+ schema: ErrorSchema,
+ },
+ },
+ },
},
});