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";