aboutsummaryrefslogtreecommitdiffstats
path: root/packages/open-api
diff options
context:
space:
mode:
Diffstat (limited to 'packages/open-api')
-rw-r--r--packages/open-api/hoarder-openapi-spec.json163
-rw-r--r--packages/open-api/lib/bookmarks.ts92
2 files changed, 255 insertions, 0 deletions
diff --git a/packages/open-api/hoarder-openapi-spec.json b/packages/open-api/hoarder-openapi-spec.json
index fecea0c2..92088f48 100644
--- a/packages/open-api/hoarder-openapi-spec.json
+++ b/packages/open-api/hoarder-openapi-spec.json
@@ -25,6 +25,10 @@
}
},
"schemas": {
+ "AssetId": {
+ "type": "string",
+ "example": "ieidlxygmwj87oxz5hxttoc8"
+ },
"BookmarkId": {
"type": "string",
"example": "ieidlxygmwj87oxz5hxttoc8"
@@ -435,6 +439,14 @@
}
},
"parameters": {
+ "AssetId": {
+ "schema": {
+ "$ref": "#/components/schemas/AssetId"
+ },
+ "required": true,
+ "name": "assetId",
+ "in": "path"
+ },
"BookmarkId": {
"schema": {
"$ref": "#/components/schemas/BookmarkId"
@@ -1008,6 +1020,157 @@
}
}
},
+ "/bookmarks/{bookmarkId}/assets": {
+ "post": {
+ "description": "Attach a new asset to a bookmark",
+ "summary": "Attach asset",
+ "tags": [
+ "Bookmarks"
+ ],
+ "security": [
+ {
+ "bearerAuth": []
+ }
+ ],
+ "parameters": [
+ {
+ "$ref": "#/components/parameters/BookmarkId"
+ }
+ ],
+ "requestBody": {
+ "description": "The asset to attach",
+ "content": {
+ "application/json": {
+ "schema": {
+ "type": "object",
+ "properties": {
+ "id": {
+ "type": "string"
+ },
+ "assetType": {
+ "type": "string",
+ "enum": [
+ "screenshot",
+ "bannerImage",
+ "fullPageArchive",
+ "video",
+ "bookmarkAsset",
+ "unknown"
+ ]
+ }
+ },
+ "required": [
+ "id",
+ "assetType"
+ ]
+ }
+ }
+ }
+ },
+ "responses": {
+ "201": {
+ "description": "The attached asset",
+ "content": {
+ "application/json": {
+ "schema": {
+ "type": "object",
+ "properties": {
+ "id": {
+ "type": "string"
+ },
+ "assetType": {
+ "type": "string",
+ "enum": [
+ "screenshot",
+ "bannerImage",
+ "fullPageArchive",
+ "video",
+ "bookmarkAsset",
+ "unknown"
+ ]
+ }
+ },
+ "required": [
+ "id",
+ "assetType"
+ ]
+ }
+ }
+ }
+ }
+ }
+ }
+ },
+ "/bookmarks/{bookmarkId}/assets/{assetId}": {
+ "put": {
+ "description": "Replace an existing asset with a new one",
+ "summary": "Replace asset",
+ "tags": [
+ "Bookmarks"
+ ],
+ "security": [
+ {
+ "bearerAuth": []
+ }
+ ],
+ "parameters": [
+ {
+ "$ref": "#/components/parameters/BookmarkId"
+ },
+ {
+ "$ref": "#/components/parameters/AssetId"
+ }
+ ],
+ "requestBody": {
+ "description": "The new asset to replace with",
+ "content": {
+ "application/json": {
+ "schema": {
+ "type": "object",
+ "properties": {
+ "assetId": {
+ "type": "string"
+ }
+ },
+ "required": [
+ "assetId"
+ ]
+ }
+ }
+ }
+ },
+ "responses": {
+ "204": {
+ "description": "No content - asset was replaced successfully"
+ }
+ }
+ },
+ "delete": {
+ "description": "Detach an asset from a bookmark",
+ "summary": "Detach asset",
+ "tags": [
+ "Bookmarks"
+ ],
+ "security": [
+ {
+ "bearerAuth": []
+ }
+ ],
+ "parameters": [
+ {
+ "$ref": "#/components/parameters/BookmarkId"
+ },
+ {
+ "$ref": "#/components/parameters/AssetId"
+ }
+ ],
+ "responses": {
+ "204": {
+ "description": "No content - asset was detached successfully"
+ }
+ }
+ }
+ },
"/lists": {
"get": {
"description": "Get all lists",
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",
+ },
+ },
+});