From 659f5c9b0f4c07ae0ed37add196948822c77cad9 Mon Sep 17 00:00:00 2001 From: rito528 <39003544+rito528@users.noreply.github.com> Date: Mon, 11 Nov 2024 17:37:20 +0900 Subject: [PATCH] =?UTF-8?q?feat:=20=E9=80=9A=E7=9F=A5=E3=81=AB=E9=96=A2?= =?UTF-8?q?=E3=81=99=E3=82=8B=20API=20=E3=82=B9=E3=82=AD=E3=83=BC=E3=83=9E?= =?UTF-8?q?=E3=81=AE=E5=AE=9A=E7=BE=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/endpoints/notification.tsp | 43 ++++++++++++++++++++++++++++++++++ src/main.tsp | 1 + src/models/notification.tsp | 20 ++++++++++++++++ 3 files changed, 64 insertions(+) create mode 100644 src/endpoints/notification.tsp create mode 100644 src/models/notification.tsp diff --git a/src/endpoints/notification.tsp b/src/endpoints/notification.tsp new file mode 100644 index 0000000..87a0762 --- /dev/null +++ b/src/endpoints/notification.tsp @@ -0,0 +1,43 @@ +import "@typespec/http"; +import "@typespec/rest"; +import "../models/errors.tsp"; +import "../models/notification.tsp"; + +using TypeSpec.Http; +using TypeSpec.Rest; + +@service +namespace SeichiPortalApiSchema; + +@tag("Notifications") +@route("/notifications") +namespace Notifications { + @get + @summary("通知一覧を返す") + op notifications(): { + @statusCode statusCode: 200; + @body body: Notification[]; + } | { + @statusCode statusCode: 401 | 403 | 500; + @body body: Error; + }; + + @post + @summary("すべて既読にする") + op readAll(): { + @statusCode statusCode: 204; + } | { + @statusCode statusCode: 401 | 403 | 500; + @body body: Error; + }; + + @post + @summary("通知を既読にする") + @route("/{id}") + op read(@path id: NotificationId): { + @statusCode statusCode: 204; + } | { + @statusCode statusCode: 401 | 403 | 404 | 500; + @body body: Error; + }; +} diff --git a/src/main.tsp b/src/main.tsp index 84533fb..f7e398b 100644 --- a/src/main.tsp +++ b/src/main.tsp @@ -1,6 +1,7 @@ import "./endpoints/forms.tsp"; import "./endpoints/users.tsp"; import "./endpoints/session.tsp"; +import "./endpoints/notification.tsp"; import "@typespec/openapi"; using TypeSpec.Http; diff --git a/src/models/notification.tsp b/src/models/notification.tsp new file mode 100644 index 0000000..7ad86b4 --- /dev/null +++ b/src/models/notification.tsp @@ -0,0 +1,20 @@ +enum NotificationSource { + FormMessage, +} + +model NotificationSourceInfo { + source: NotificationSource; + url: string; +} + +@format("uuid") +scalar NotificationId extends string; + +model Notification { + @visibility("read") + id: NotificationId; + + source: NotificationSourceInfo; + title: string; + is_read: boolean; +}