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 定義の実装 #171

Merged
merged 1 commit into from
Oct 26, 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
63 changes: 63 additions & 0 deletions src/endpoints/messages.tsp
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
import "@typespec/http";
import "@typespec/rest";
import "../models/errors.tsp";
import "../models/user.tsp";
import "../models/message.tsp";

using TypeSpec.Http;
using TypeSpec.Rest;

namespace SeichiPortalApiSchema;

@tag("Messages")
@route("/messages")
namespace Messages {
@post
@summary("メッセージの新規作成")
op create(
@header
contentType: "application/json",

@body body: {
related_answer_id: uint32;
body: string;
},
): {
@statusCode statusCode: 201;
@body body: {
id: uint32;
};
} | {
@statusCode statusCode: 400 | 401 | 403 | 500;
@body body: Error;
};

@get
@route("/{related_answer_id}")
@summary("メッセージの一覧取得")
op list(
@path
related_answer_id: uint32,
): {
@statusCode statusCode: 200;
@body body: {
messages: Message[];
};
} | {
@statusCode statusCode: 400 | 401 | 403 | 500;
@body body: Error;
};

@delete
@route("/{message_id}")
@summary("メッセージの削除")
op delete(
@path
message_id: uint32,
): {
@statusCode statusCode: 204;
} | {
@statusCode statusCode: 400 | 401 | 403 | 500;
@body body: Error;
};
}
1 change: 1 addition & 0 deletions src/main.tsp
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import "./endpoints/forms.tsp";
import "./endpoints/messages.tsp";
import "./endpoints/users.tsp";
import "./endpoints/session.tsp";
import "@typespec/openapi";
Expand Down
1 change: 1 addition & 0 deletions src/models/errors.tsp
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
enum ErrorCode {
FORM_NOT_FOUND,
ANSWER_NOT_FOUND,
MESSAGE_NOT_FOUND,
OUT_OF_PERIOD,
DO_NOT_HAVE_PERMISSION_TO_POST_FORM_COMMENT,
DO_NOT_HAVE_PERMISSION_TO_GET_ANSWERS,
Expand Down
7 changes: 7 additions & 0 deletions src/models/message.tsp
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import "../endpoints/users.tsp";

model Message {
body: string;
sender: User;
timestamp: utcDateTime;
}