From fbc616b2850766000b0d7dd423422e6b3df7fe00 Mon Sep 17 00:00:00 2001 From: rito528 <39003544+rito528@users.noreply.github.com> Date: Fri, 1 Nov 2024 23:58:56 +0900 Subject: [PATCH 1/2] =?UTF-8?q?fea:t=20=E3=83=A1=E3=83=83=E3=82=BB?= =?UTF-8?q?=E3=83=BC=E3=82=B8=E6=9B=B4=E6=96=B0=E7=94=A8=20API=20=E3=81=AE?= =?UTF-8?q?=E5=AE=9A=E7=BE=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/endpoints/messages.tsp | 43 ++++++++++++++++++++++++++++---------- 1 file changed, 32 insertions(+), 11 deletions(-) diff --git a/src/endpoints/messages.tsp b/src/endpoints/messages.tsp index ee22b98..756c7d7 100644 --- a/src/endpoints/messages.tsp +++ b/src/endpoints/messages.tsp @@ -27,6 +27,9 @@ namespace Messages { @body body: { id: uint32; }; + @header header: { + Location: string; + }; } | { @statusCode statusCode: 400 | 401 | 403 | 500; @body body: Error; @@ -48,16 +51,34 @@ namespace Messages { @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; - }; + namespace InvidualMessage { + @patch + @summary("メッセージの更新") + op update( + @path + message_id: uint32, + + @body body: { + body: string; + }, + ): { + @statusCode statusCode: 204; + } | { + @statusCode statusCode: 400 | 401 | 403 | 500; + @body body: Error; + }; + + @delete + @summary("メッセージの削除") + op delete( + @path + message_id: uint32, + ): { + @statusCode statusCode: 204; + } | { + @statusCode statusCode: 400 | 401 | 403 | 500; + @body body: Error; + }; + } } From 6d68221d86932a89004cd98cbdc325ccb7c23f2d Mon Sep 17 00:00:00 2001 From: rito528 <39003544+rito528@users.noreply.github.com> Date: Sat, 2 Nov 2024 15:11:51 +0900 Subject: [PATCH 2/2] =?UTF-8?q?fix:=20=E3=83=A1=E3=83=83=E3=82=BB=E3=83=BC?= =?UTF-8?q?=E3=82=B8=E3=81=AB=E9=96=A2=E3=81=99=E3=82=8B=E3=82=A8=E3=83=B3?= =?UTF-8?q?=E3=83=89=E3=83=9D=E3=82=A4=E3=83=B3=E3=83=88=E3=81=AE=20URL=20?= =?UTF-8?q?=E3=82=92=E5=A4=89=E6=9B=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/endpoints/forms.tsp | 75 ++++++++++++++++++++++++++++++++++ src/endpoints/messages.tsp | 84 -------------------------------------- src/main.tsp | 1 - 3 files changed, 75 insertions(+), 85 deletions(-) delete mode 100644 src/endpoints/messages.tsp diff --git a/src/endpoints/forms.tsp b/src/endpoints/forms.tsp index 0070c00..e7f7af8 100644 --- a/src/endpoints/forms.tsp +++ b/src/endpoints/forms.tsp @@ -2,6 +2,7 @@ import "@typespec/http"; import "@typespec/rest"; import "../models/errors.tsp"; import "../models/form.tsp"; +import "../models/message.tsp"; @service namespace SeichiPortalApiSchema; @@ -295,6 +296,80 @@ namespace Forms { @statusCode statusCode: 400 | 401 | 403 | 500; @body body: Error; }; + + @tag("Messages") + @route("/messages") + namespace Messages { + @post + @summary("メッセージの新規作成") + op create_message( + @header + contentType: "application/json", + + @path answerId: uint32, + @body body: { + body: string; + }, + ): { + @statusCode statusCode: 201; + @body body: { + id: uint32; + }; + @header header: { + Location: string; + }; + } | { + @statusCode statusCode: 400 | 401 | 403 | 500; + @body body: Error; + }; + + @get + @summary("メッセージの一覧取得") + op messages(@path answerId: uint32): { + @statusCode statusCode: 200; + @body body: { + messages: Message[]; + }; + } | { + @statusCode statusCode: 400 | 401 | 403 | 500; + @body body: Error; + }; + + @route("/{message_id}") + namespace InvidualMessage { + @patch + @summary("メッセージの更新") + op update_message( + @path answerId: uint32, + + @path + message_id: uint32, + + @body body: { + body: string; + }, + ): { + @statusCode statusCode: 204; + } | { + @statusCode statusCode: 400 | 401 | 403 | 500; + @body body: Error; + }; + + @delete + @summary("メッセージの削除") + op delete_message( + @path answerId: uint32, + + @path + message_id: uint32, + ): { + @statusCode statusCode: 204; + } | { + @statusCode statusCode: 400 | 401 | 403 | 500; + @body body: Error; + }; + } + } } @route("/comment") diff --git a/src/endpoints/messages.tsp b/src/endpoints/messages.tsp deleted file mode 100644 index 756c7d7..0000000 --- a/src/endpoints/messages.tsp +++ /dev/null @@ -1,84 +0,0 @@ -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; - }; - @header header: { - Location: string; - }; - } | { - @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; - }; - - @route("/{message_id}") - namespace InvidualMessage { - @patch - @summary("メッセージの更新") - op update( - @path - message_id: uint32, - - @body body: { - body: string; - }, - ): { - @statusCode statusCode: 204; - } | { - @statusCode statusCode: 400 | 401 | 403 | 500; - @body body: Error; - }; - - @delete - @summary("メッセージの削除") - op delete( - @path - message_id: uint32, - ): { - @statusCode statusCode: 204; - } | { - @statusCode statusCode: 400 | 401 | 403 | 500; - @body body: Error; - }; - } -} diff --git a/src/main.tsp b/src/main.tsp index a1b15ce..84533fb 100644 --- a/src/main.tsp +++ b/src/main.tsp @@ -1,5 +1,4 @@ import "./endpoints/forms.tsp"; -import "./endpoints/messages.tsp"; import "./endpoints/users.tsp"; import "./endpoints/session.tsp"; import "@typespec/openapi";