Skip to content

Commit

Permalink
api: Add tag ids and support variable baseURL
Browse files Browse the repository at this point in the history
  • Loading branch information
MohamedBassem committed Oct 20, 2024
1 parent 6ffa51d commit b476e91
Show file tree
Hide file tree
Showing 5 changed files with 98 additions and 2 deletions.
68 changes: 67 additions & 1 deletion packages/open-api/hoarder-openapi-spec.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,13 @@
},
"servers": [
{
"url": "v1"
"url": "{address}/api/v1",
"variables": {
"address": {
"default": "https://try.hoarder.app",
"description": "The address of the hoarder server"
}
}
}
],
"components": {
Expand Down Expand Up @@ -368,6 +374,9 @@
"get": {
"description": "Get all bookmarks",
"summary": "Get all bookmarks",
"tags": [
"Bookmarks"
],
"security": [
{
"bearerAuth": []
Expand Down Expand Up @@ -423,6 +432,9 @@
"post": {
"description": "Create a new bookmark",
"summary": "Create a new bookmark",
"tags": [
"Bookmarks"
],
"security": [
{
"bearerAuth": []
Expand Down Expand Up @@ -584,6 +596,9 @@
"get": {
"description": "Get bookmark by its id",
"summary": "Get a single bookmark",
"tags": [
"Bookmarks"
],
"security": [
{
"bearerAuth": []
Expand All @@ -610,6 +625,9 @@
"delete": {
"description": "Delete bookmark by its id",
"summary": "Delete a bookmark",
"tags": [
"Bookmarks"
],
"security": [
{
"bearerAuth": []
Expand All @@ -629,6 +647,9 @@
"patch": {
"description": "Update bookmark by its id",
"summary": "Update a bookmark",
"tags": [
"Bookmarks"
],
"security": [
{
"bearerAuth": []
Expand Down Expand Up @@ -725,6 +746,9 @@
"post": {
"description": "Attach tags to a bookmark",
"summary": "Attach tags to a bookmark",
"tags": [
"Bookmarks"
],
"security": [
{
"bearerAuth": []
Expand Down Expand Up @@ -791,6 +815,9 @@
"delete": {
"description": "Detach tags from a bookmark",
"summary": "Detach tags from a bookmark",
"tags": [
"Bookmarks"
],
"security": [
{
"bearerAuth": []
Expand Down Expand Up @@ -859,6 +886,9 @@
"get": {
"description": "Get all lists",
"summary": "Get all lists",
"tags": [
"Lists"
],
"security": [
{
"bearerAuth": []
Expand Down Expand Up @@ -891,6 +921,9 @@
"post": {
"description": "Create a new list",
"summary": "Create a new list",
"tags": [
"Lists"
],
"security": [
{
"bearerAuth": []
Expand Down Expand Up @@ -942,6 +975,9 @@
"get": {
"description": "Get list by its id",
"summary": "Get a single list",
"tags": [
"Lists"
],
"security": [
{
"bearerAuth": []
Expand All @@ -968,6 +1004,9 @@
"delete": {
"description": "Delete list by its id",
"summary": "Delete a list",
"tags": [
"Lists"
],
"security": [
{
"bearerAuth": []
Expand All @@ -989,6 +1028,9 @@
"patch": {
"description": "Update list by its id",
"summary": "Update a list",
"tags": [
"Lists"
],
"security": [
{
"bearerAuth": []
Expand Down Expand Up @@ -1041,6 +1083,9 @@
"get": {
"description": "Get the bookmarks in a list",
"summary": "Get a bookmarks in a list",
"tags": [
"Lists"
],
"security": [
{
"bearerAuth": []
Expand Down Expand Up @@ -1085,6 +1130,9 @@
"put": {
"description": "Add the bookmarks to a list",
"summary": "Add a bookmark to a list",
"tags": [
"Lists"
],
"security": [
{
"bearerAuth": []
Expand All @@ -1107,6 +1155,9 @@
"delete": {
"description": "Remove the bookmarks from a list",
"summary": "Remove a bookmark from a list",
"tags": [
"Lists"
],
"security": [
{
"bearerAuth": []
Expand All @@ -1131,6 +1182,9 @@
"get": {
"description": "Get all tags",
"summary": "Get all tags",
"tags": [
"Tags"
],
"security": [
{
"bearerAuth": []
Expand Down Expand Up @@ -1165,6 +1219,9 @@
"get": {
"description": "Get tag by its id",
"summary": "Get a single tag",
"tags": [
"Tags"
],
"security": [
{
"bearerAuth": []
Expand All @@ -1191,6 +1248,9 @@
"delete": {
"description": "Delete tag by its id",
"summary": "Delete a tag",
"tags": [
"Tags"
],
"security": [
{
"bearerAuth": []
Expand All @@ -1210,6 +1270,9 @@
"patch": {
"description": "Update tag by its id",
"summary": "Update a tag",
"tags": [
"Tags"
],
"security": [
{
"bearerAuth": []
Expand Down Expand Up @@ -1253,6 +1316,9 @@
"get": {
"description": "Get the bookmarks with the tag",
"summary": "Get a bookmarks with the tag",
"tags": [
"Tags"
],
"security": [
{
"bearerAuth": []
Expand Down
12 changes: 11 additions & 1 deletion packages/open-api/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,17 @@ function getOpenApiDocumentation() {
title: "Hoarder API",
description: "The API for the Hoarder app",
},
servers: [{ url: "v1" }],
servers: [
{
url: "{address}/api/v1",
variables: {
address: {
default: "https://try.hoarder.app",
description: "The address of the hoarder server",
},
},
},
],
});
}

Expand Down
7 changes: 7 additions & 0 deletions packages/open-api/lib/bookmarks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ registry.registerPath({
path: "/bookmarks",
description: "Get all bookmarks",
summary: "Get all bookmarks",
tags: ["Bookmarks"],
security: [{ [BearerAuth.name]: [] }],
request: {
query: z
Expand All @@ -64,6 +65,7 @@ registry.registerPath({
path: "/bookmarks",
description: "Create a new bookmark",
summary: "Create a new bookmark",
tags: ["Bookmarks"],
security: [{ [BearerAuth.name]: [] }],
request: {
body: {
Expand Down Expand Up @@ -91,6 +93,7 @@ registry.registerPath({
path: "/bookmarks/{bookmarkId}",
description: "Get bookmark by its id",
summary: "Get a single bookmark",
tags: ["Bookmarks"],
security: [{ [BearerAuth.name]: [] }],
request: {
params: z.object({ bookmarkId: BookmarkIdSchema }),
Expand All @@ -112,6 +115,7 @@ registry.registerPath({
path: "/bookmarks/{bookmarkId}",
description: "Delete bookmark by its id",
summary: "Delete a bookmark",
tags: ["Bookmarks"],
security: [{ [BearerAuth.name]: [] }],
request: {
params: z.object({ bookmarkId: BookmarkIdSchema }),
Expand All @@ -128,6 +132,7 @@ registry.registerPath({
path: "/bookmarks/{bookmarkId}",
description: "Update bookmark by its id",
summary: "Update a bookmark",
tags: ["Bookmarks"],
security: [{ [BearerAuth.name]: [] }],
request: {
params: z.object({ bookmarkId: BookmarkIdSchema }),
Expand Down Expand Up @@ -158,6 +163,7 @@ registry.registerPath({
path: "/bookmarks/{bookmarkId}/tags",
description: "Attach tags to a bookmark",
summary: "Attach tags to a bookmark",
tags: ["Bookmarks"],
security: [{ [BearerAuth.name]: [] }],
request: {
params: z.object({ bookmarkId: BookmarkIdSchema }),
Expand Down Expand Up @@ -187,6 +193,7 @@ registry.registerPath({
path: "/bookmarks/{bookmarkId}/tags",
description: "Detach tags from a bookmark",
summary: "Detach tags from a bookmark",
tags: ["Bookmarks"],
security: [{ [BearerAuth.name]: [] }],
request: {
params: z.object({ bookmarkId: BookmarkIdSchema }),
Expand Down
8 changes: 8 additions & 0 deletions packages/open-api/lib/lists.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ registry.registerPath({
path: "/lists",
description: "Get all lists",
summary: "Get all lists",
tags: ["Lists"],
security: [{ [BearerAuth.name]: [] }],
request: {},
responses: {
Expand All @@ -55,6 +56,7 @@ registry.registerPath({
path: "/lists",
description: "Create a new list",
summary: "Create a new list",
tags: ["Lists"],
security: [{ [BearerAuth.name]: [] }],
request: {
body: {
Expand Down Expand Up @@ -82,6 +84,7 @@ registry.registerPath({
path: "/lists/{listId}",
description: "Get list by its id",
summary: "Get a single list",
tags: ["Lists"],
security: [{ [BearerAuth.name]: [] }],
request: {
params: z.object({ listId: ListIdSchema }),
Expand All @@ -103,6 +106,7 @@ registry.registerPath({
path: "/lists/{listId}",
description: "Delete list by its id",
summary: "Delete a list",
tags: ["Lists"],
security: [{ [BearerAuth.name]: [] }],
request: {
params: z.object({ listId: ListIdSchema }),
Expand All @@ -119,6 +123,7 @@ registry.registerPath({
path: "/list/{listId}",
description: "Update list by its id",
summary: "Update a list",
tags: ["Lists"],
security: [{ [BearerAuth.name]: [] }],
request: {
params: z.object({ listId: ListIdSchema }),
Expand Down Expand Up @@ -149,6 +154,7 @@ registry.registerPath({
path: "/lists/{listId}/bookmarks",
description: "Get the bookmarks in a list",
summary: "Get a bookmarks in a list",
tags: ["Lists"],
security: [{ [BearerAuth.name]: [] }],
request: {
params: z.object({ listId: ListIdSchema }),
Expand All @@ -171,6 +177,7 @@ registry.registerPath({
path: "/lists/{listId}/bookmarks/{bookmarkId}",
description: "Add the bookmarks to a list",
summary: "Add a bookmark to a list",
tags: ["Lists"],
security: [{ [BearerAuth.name]: [] }],
request: {
params: z.object({ listId: ListIdSchema, bookmarkId: BookmarkIdSchema }),
Expand All @@ -187,6 +194,7 @@ registry.registerPath({
path: "/lists/{listId}/bookmarks/{bookmarkId}",
description: "Remove the bookmarks from a list",
summary: "Remove a bookmark from a list",
tags: ["Lists"],
security: [{ [BearerAuth.name]: [] }],
request: {
params: z.object({ listId: ListIdSchema, bookmarkId: BookmarkIdSchema }),
Expand Down
5 changes: 5 additions & 0 deletions packages/open-api/lib/tags.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ registry.registerPath({
path: "/tags",
description: "Get all tags",
summary: "Get all tags",
tags: ["Tags"],
security: [{ [BearerAuth.name]: [] }],
request: {},
responses: {
Expand All @@ -54,6 +55,7 @@ registry.registerPath({
path: "/tags/{tagId}",
description: "Get tag by its id",
summary: "Get a single tag",
tags: ["Tags"],
security: [{ [BearerAuth.name]: [] }],
request: {
params: z.object({ tagId: TagIdSchema }),
Expand All @@ -75,6 +77,7 @@ registry.registerPath({
path: "/tags/{tagId}",
description: "Delete tag by its id",
summary: "Delete a tag",
tags: ["Tags"],
security: [{ [BearerAuth.name]: [] }],
request: {
params: z.object({ tagId: TagIdSchema }),
Expand All @@ -91,6 +94,7 @@ registry.registerPath({
path: "/tags/{tagId}",
description: "Update tag by its id",
summary: "Update a tag",
tags: ["Tags"],
security: [{ [BearerAuth.name]: [] }],
request: {
params: z.object({ tagId: TagIdSchema }),
Expand Down Expand Up @@ -121,6 +125,7 @@ registry.registerPath({
path: "/tags/{tagId}/bookmarks",
description: "Get the bookmarks with the tag",
summary: "Get a bookmarks with the tag",
tags: ["Tags"],
security: [{ [BearerAuth.name]: [] }],
request: {
params: z.object({ tagId: TagIdSchema }),
Expand Down

0 comments on commit b476e91

Please sign in to comment.