diff options
Diffstat (limited to 'packages/open-api/lib/bookmarks.ts')
| -rw-r--r-- | packages/open-api/lib/bookmarks.ts | 92 |
1 files changed, 92 insertions, 0 deletions
diff --git a/packages/open-api/lib/bookmarks.ts b/packages/open-api/lib/bookmarks.ts index 12a122fa..09288a4b 100644 --- a/packages/open-api/lib/bookmarks.ts +++ b/packages/open-api/lib/bookmarks.ts @@ -5,6 +5,7 @@ import { import { z } from "zod"; import { + zAssetSchema, zBareBookmarkSchema, zManipulatedTagSchema, zNewBookmarkRequestSchema, @@ -23,6 +24,17 @@ import { TagIdSchema } from "./tags"; export const registry = new OpenAPIRegistry(); extendZodWithOpenApi(z); +export const AssetIdSchema = registry.registerParameter( + "AssetId", + z.string().openapi({ + param: { + name: "assetId", + in: "path", + }, + example: "ieidlxygmwj87oxz5hxttoc8", + }), +); + export const BookmarkIdSchema = registry.registerParameter( "BookmarkId", z.string().openapi({ @@ -240,3 +252,83 @@ registry.registerPath({ }, }, }); + +registry.registerPath({ + method: "post", + path: "/bookmarks/{bookmarkId}/assets", + description: "Attach a new asset to a bookmark", + summary: "Attach asset", + tags: ["Bookmarks"], + security: [{ [BearerAuth.name]: [] }], + request: { + params: z.object({ bookmarkId: BookmarkIdSchema }), + body: { + description: "The asset to attach", + content: { + "application/json": { + schema: zAssetSchema, + }, + }, + }, + }, + responses: { + 201: { + description: "The attached asset", + content: { + "application/json": { + schema: zAssetSchema, + }, + }, + }, + }, +}); + +registry.registerPath({ + method: "put", + path: "/bookmarks/{bookmarkId}/assets/{assetId}", + description: "Replace an existing asset with a new one", + summary: "Replace asset", + tags: ["Bookmarks"], + security: [{ [BearerAuth.name]: [] }], + request: { + params: z.object({ + bookmarkId: BookmarkIdSchema, + assetId: AssetIdSchema, + }), + body: { + description: "The new asset to replace with", + content: { + "application/json": { + schema: z.object({ + assetId: z.string(), + }), + }, + }, + }, + }, + responses: { + 204: { + description: "No content - asset was replaced successfully", + }, + }, +}); + +registry.registerPath({ + method: "delete", + path: "/bookmarks/{bookmarkId}/assets/{assetId}", + description: "Detach an asset from a bookmark", + summary: "Detach asset", + tags: ["Bookmarks"], + security: [{ [BearerAuth.name]: [] }], + request: { + params: z.object({ + bookmarkId: BookmarkIdSchema, + assetId: AssetIdSchema, + }), + }, + responses: { + 204: { + description: "No content - asset was detached successfully", + }, + }, +}); |
