Skip to content

Commit

Permalink
Merge pull request #178 from GiganticMinecraft/feat/notifications
Browse files Browse the repository at this point in the history
feat: 通知に関する API スキーマの定義
  • Loading branch information
rito528 authored Nov 11, 2024
2 parents a147f6a + 659f5c9 commit bebeea4
Show file tree
Hide file tree
Showing 3 changed files with 64 additions and 0 deletions.
43 changes: 43 additions & 0 deletions src/endpoints/notification.tsp
Original file line number Diff line number Diff line change
@@ -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;
};
}
1 change: 1 addition & 0 deletions src/main.tsp
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
20 changes: 20 additions & 0 deletions src/models/notification.tsp
Original file line number Diff line number Diff line change
@@ -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;
}

0 comments on commit bebeea4

Please sign in to comment.