From 0c2af179c6c64effdd604e8dee4e3ae6f5c4ec43 Mon Sep 17 00:00:00 2001 From: rito528 <39003544+rito528@users.noreply.github.com> Date: Mon, 16 Dec 2024 12:42:56 +0900 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=A8=99=E6=BA=96=E7=9A=84=E3=81=AB?= =?UTF-8?q?=E6=83=B3=E5=AE=9A=E3=81=95=E3=82=8C=E3=82=8B=20CRUD=20?= =?UTF-8?q?=E6=93=8D=E4=BD=9C=E7=94=A8=E3=81=AE=E3=83=86=E3=83=B3=E3=83=97?= =?UTF-8?q?=E3=83=AC=E3=83=BC=E3=83=88=E3=82=92=E5=AE=9A=E7=BE=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- spec/general/interfaces/endpoints.tsp | 75 +++++++++++++++++++++++++++ 1 file changed, 75 insertions(+) create mode 100644 spec/general/interfaces/endpoints.tsp diff --git a/spec/general/interfaces/endpoints.tsp b/spec/general/interfaces/endpoints.tsp new file mode 100644 index 0000000..d70a490 --- /dev/null +++ b/spec/general/interfaces/endpoints.tsp @@ -0,0 +1,75 @@ +import "@typespec/http"; +import "../../models/errors.tsp"; +import "../types/id.tsp"; + +using TypeSpec.Http; + +interface GeneralCRUD { + @post + create( + @header + contentType: "application/json", + + @body body: { + value: T; + }, + ): { + @statusCode statusCode: 201; + @header Location: string; + } | { + @statusCode statusCode: 400 | 401 | 403 | 500; + @body body: Error; + }; + + @get + get( + @header + contentType: "application/json", + + @body body: { + id: ID; + }, + ): { + @statusCode statusCode: 200; + @body body: T; + } | { + @statusCode statusCode: 400 | 401 | 403 | 404 | 500; + @body body: Error; + }; + + @get + list(): { + @statusCode statusCode: 200; + @body body: T[]; + } | { + @statusCode statusCode: 400 | 401 | 403 | 500; + @body body: Error; + }; + + @patch + update( + @header + contentType: "application/json", + + @body body: T, + ): { + @statusCode statusCode: 200; + @body body: T; + } | { + @statusCode statusCode: 400 | 401 | 403 | 404 | 500; + @body body: Error; + }; + + @delete + delete( + @header + contentType: "application/json", + + @body body: ID, + ): { + @statusCode statusCode: 204; + } | { + @statusCode statusCode: 400 | 401 | 403 | 500; + @body body: Error; + }; +}