From a5ae67c241d8cdd452acd4d98800ec61740c041f Mon Sep 17 00:00:00 2001 From: Mohamed Bassem Date: Sun, 18 May 2025 19:12:27 +0000 Subject: feat(api): Expose the endpoint to create a new tag --- packages/open-api/karakeep-openapi-spec.json | 69 +++++++++++++++++++++++++++- packages/open-api/lib/tags.ts | 33 ++++++++++++- 2 files changed, 100 insertions(+), 2 deletions(-) (limited to 'packages/open-api') diff --git a/packages/open-api/karakeep-openapi-spec.json b/packages/open-api/karakeep-openapi-spec.json index dbc2e5d0..15fa246b 100644 --- a/packages/open-api/karakeep-openapi-spec.json +++ b/packages/open-api/karakeep-openapi-spec.json @@ -2240,6 +2240,61 @@ } } } + }, + "post": { + "description": "Create a new tag", + "summary": "Create a new tag", + "tags": [ + "Tags" + ], + "security": [ + { + "bearerAuth": [] + } + ], + "requestBody": { + "description": "The data to create the tag with.", + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "name": { + "type": "string", + "minLength": 1 + } + }, + "required": [ + "name" + ] + } + } + } + }, + "responses": { + "201": { + "description": "The created tag", + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "id": { + "type": "string" + }, + "name": { + "type": "string" + } + }, + "required": [ + "id", + "name" + ] + } + } + } + } + } } }, "/tags/{tagId}": { @@ -2375,7 +2430,19 @@ "content": { "application/json": { "schema": { - "$ref": "#/components/schemas/Tag" + "type": "object", + "properties": { + "id": { + "type": "string" + }, + "name": { + "type": "string" + } + }, + "required": [ + "id", + "name" + ] } } } diff --git a/packages/open-api/lib/tags.ts b/packages/open-api/lib/tags.ts index b8136741..0a4f62cb 100644 --- a/packages/open-api/lib/tags.ts +++ b/packages/open-api/lib/tags.ts @@ -6,7 +6,9 @@ import { z } from "zod"; import { zSortOrder } from "@karakeep/shared/types/bookmarks"; import { + zCreateTagRequestSchema, zGetTagResponseSchema, + zTagBasicSchema, zUpdateTagRequestSchema, } from "@karakeep/shared/types/tags"; @@ -56,6 +58,35 @@ registry.registerPath({ }, }); +registry.registerPath({ + method: "post", + path: "/tags", + description: "Create a new tag", + summary: "Create a new tag", + tags: ["Tags"], + security: [{ [BearerAuth.name]: [] }], + request: { + body: { + description: "The data to create the tag with.", + content: { + "application/json": { + schema: zCreateTagRequestSchema, + }, + }, + }, + }, + responses: { + 201: { + description: "The created tag", + content: { + "application/json": { + schema: zTagBasicSchema, + }, + }, + }, + }, +}); + registry.registerPath({ method: "get", path: "/tags/{tagId}", @@ -135,7 +166,7 @@ registry.registerPath({ description: "The updated tag", content: { "application/json": { - schema: TagSchema, + schema: zTagBasicSchema, }, }, }, -- cgit v1.2.3-70-g09d2