Skip to content

Commit

Permalink
feat: 通知に関する API スキーマの定義
Browse files Browse the repository at this point in the history
rito528 committed Nov 11, 2024

Verified

This commit was signed with the committer’s verified signature.
rito528 rito528
1 parent a147f6a commit 659f5c9
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;
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 659f5c9

Please sign in to comment.