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; +}