-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #171 from GiganticMinecraft/feat/message-api
feat: メッセージ操作用 API 定義の実装
- Loading branch information
Showing
4 changed files
with
72 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} |