Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: 通知に関する API スキーマの定義 #178

Merged
merged 1 commit into from
Nov 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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;
}