diff --git a/.idea/workspace.xml b/.idea/workspace.xml index 5115826..72dad8b 100644 --- a/.idea/workspace.xml +++ b/.idea/workspace.xml @@ -5,17 +5,15 @@ - - - - - - - - - - - + + + + + + + + + + @@ -43,9 +46,9 @@ - + { + "associatedIndex": 8 +} + + + \ No newline at end of file diff --git a/build.gradle b/build.gradle index ceb8f35..636d5b2 100644 --- a/build.gradle +++ b/build.gradle @@ -1,7 +1,8 @@ plugins { id 'java' - id 'org.springframework.boot' version '4.0.0' - id 'io.spring.dependency-management' version '1.1.7' + id 'org.springframework.boot' version '3.2.5' + id 'io.spring.dependency-management' version '1.1.5' + id 'org.openapi.generator' version '7.5.0' } group = 'com.example' @@ -19,11 +20,39 @@ } dependencies { - implementation 'org.springframework.boot:spring-boot-starter-jersey' - testImplementation 'org.springframework.boot:spring-boot-starter-jersey-test' + implementation 'org.springframework.boot:spring-boot-starter-web' + implementation 'org.springframework.boot:spring-boot-starter-validation' + implementation 'org.springdoc:springdoc-openapi-starter-webmvc-ui:2.5.0' + implementation 'javax.annotation:javax.annotation-api:1.3.2' + implementation 'javax.servlet:javax.servlet-api:4.0.1' + implementation 'javax.validation:validation-api:2.0.1.Final' + implementation 'io.swagger.core.v3:swagger-annotations:2.2.21' + + testImplementation 'org.springframework.boot:spring-boot-starter-test' testRuntimeOnly 'org.junit.platform:junit-platform-launcher' } +openApiGenerate { + generatorName = "spring" + inputSpec = "$projectDir/src/main/resources/api/openapi.yml".toString() + outputDir = "$buildDir/generated".toString() + apiPackage = "com.example.tampopotest.api" + modelPackage = "com.example.tampopotest.model" + configOptions = [ + interfaceOnly: "true", + useSpringBoot3: "true", + useTags: "true" + ] +} + +sourceSets { + main { + java { + srcDir "$buildDir/generated/src/main/java" + } + } +} + tasks.named('test') { useJUnitPlatform() } diff --git a/src/main/java/com/example/tampopotest/controller/ChatRequestsController.java b/src/main/java/com/example/tampopotest/controller/ChatRequestsController.java new file mode 100644 index 0000000..92ca329 --- /dev/null +++ b/src/main/java/com/example/tampopotest/controller/ChatRequestsController.java @@ -0,0 +1,12 @@ +package com.example.tampopotest.controller; + +import com.example.tampopotest.api.ChatRequestsApi; +import com.example.tampopotest.model.ChatRequestsPostRequest; +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.RestController; + +@RestController +public class ChatRequestsController implements ChatRequestsApi { + + // ここに各エンドポイントの実装を記述します +} diff --git a/src/main/java/com/example/tampopotest/controller/ChatRoomsController.java b/src/main/java/com/example/tampopotest/controller/ChatRoomsController.java new file mode 100644 index 0000000..4e73395 --- /dev/null +++ b/src/main/java/com/example/tampopotest/controller/ChatRoomsController.java @@ -0,0 +1,11 @@ +package com.example.tampopotest.controller; + +import com.example.tampopotest.api.ChatRoomsApi; +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.RestController; + +@RestController +public class ChatRoomsController implements ChatRoomsApi { + + // ここに各エンドポイントの実装を記述します +} diff --git a/src/main/java/com/example/tampopotest/controller/FriendRequestsController.java b/src/main/java/com/example/tampopotest/controller/FriendRequestsController.java new file mode 100644 index 0000000..d26dd38 --- /dev/null +++ b/src/main/java/com/example/tampopotest/controller/FriendRequestsController.java @@ -0,0 +1,12 @@ +package com.example.tampopotest.controller; + +import com.example.tampopotest.api.FriendRequestsApi; +import com.example.tampopotest.model.FriendRequestsPostRequest; +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.RestController; + +@RestController +public class FriendRequestsController implements FriendRequestsApi { + + // ここに各エンドポイントの実装を記述します +} diff --git a/src/main/java/com/example/tampopotest/controller/FriendsController.java b/src/main/java/com/example/tampopotest/controller/FriendsController.java new file mode 100644 index 0000000..4f6dc08 --- /dev/null +++ b/src/main/java/com/example/tampopotest/controller/FriendsController.java @@ -0,0 +1,12 @@ +package com.example.tampopotest.controller; + +import com.example.tampopotest.api.FriendsApi; +import com.example.tampopotest.model.FriendsPostRequest; +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.RestController; + +@RestController +public class FriendsController implements FriendsApi { + + // ここに各エンドポイントの実装を記述します +} diff --git a/src/main/java/com/example/tampopotest/controller/UsersController.java b/src/main/java/com/example/tampopotest/controller/UsersController.java new file mode 100644 index 0000000..4fddc4d --- /dev/null +++ b/src/main/java/com/example/tampopotest/controller/UsersController.java @@ -0,0 +1,13 @@ +package com.example.tampopotest.controller; + +import com.example.tampopotest.api.UsersApi; +import com.example.tampopotest.model.LoginPostRequest; +import com.example.tampopotest.model.UsersPostRequest; +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.RestController; + +@RestController +public class UsersController implements UsersApi { + + // ここに各エンドポイントの実装を記述します +} diff --git a/src/main/java/com/example/tampopotest/controller/UsersUserIdActivitiesController.java b/src/main/java/com/example/tampopotest/controller/UsersUserIdActivitiesController.java new file mode 100644 index 0000000..28687da --- /dev/null +++ b/src/main/java/com/example/tampopotest/controller/UsersUserIdActivitiesController.java @@ -0,0 +1,11 @@ +package com.example.tampopotest.controller; + +import com.example.tampopotest.api.UsersUserIdActivitiesApi; +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.RestController; + +@RestController +public class UsersUserIdActivitiesController implements UsersUserIdActivitiesApi { + + // ここに各エンドポイントの実装を記述します +} diff --git a/src/main/java/com/example/tampopotest/controller/UsersUserIdFriendsController.java b/src/main/java/com/example/tampopotest/controller/UsersUserIdFriendsController.java new file mode 100644 index 0000000..11fcf2c --- /dev/null +++ b/src/main/java/com/example/tampopotest/controller/UsersUserIdFriendsController.java @@ -0,0 +1,11 @@ +package com.example.tampopotest.controller; + +import com.example.tampopotest.api.UsersUserIdFriendsApi; +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.RestController; + +@RestController +public class UsersUserIdFriendsController implements UsersUserIdFriendsApi { + + // ここに各エンドポイントの実装を記述します +} diff --git a/src/main/resources/api/openapi.yml b/src/main/resources/api/openapi.yml new file mode 100644 index 0000000..bdd84b7 --- /dev/null +++ b/src/main/resources/api/openapi.yml @@ -0,0 +1,1657 @@ +openapi: "3.0.3" + +info: + title: tampopo API + version: "1.0" + +servers: + - url: https://api.tampopo.app/ + +tags: + - name: users + description: アカウントの基本情報 + - name: users/{user-id}/activities + description: アクティビティの情報 + - name: users/{user-id}/friends + description: フレンド関係の情報 + - name: friend-requests + description: フレンドリクエスト関連 + - name: friends + description: フレンド関連 + - name: chat-requests + description: チャットリクエスト関連 + - name: chat-rooms + description: チャットルーム関連 + +paths: + #アカウントの基本情報 + /users: + get: + tags: + - users + summary: 全アカウント情報を返す + description: 全アカウントのID一覧を返す + responses: + '200': + description: Successful operation + content: + application/json: + schema: + type: array + items: + type: string + example: + - "user-id1" + - "user-id2" + - "user-id3" + "400": + description: 不正なリクエスト + "404": + description: データが存在しません + "500": + description: 予期せぬエラー + post: + tags: + - users + summary: 新規アカウントを作る + description: ユーザーIDとパスワードを指定して新規アカウントを作る + requestBody: + required: true + content: + application/x-www-form-urlencoded: + schema: + type: object + properties: + user-id: + type: string + description: ユーザーID + password: + type: string + description: パスワード + required: + - user-id + - password + responses: + '200': + description: Successful operation + content: + application/json: + schema: + type: object + properties: + user-id: + type: string + example: test + token: + type: string + "400": + description: 不正なリクエスト + "409": + description: ユーザーIDの重複 + "500": + description: 予期せぬエラー + + /users/{user-id}: + get: + tags: + - users + summary: 単一アカウントの情報を返す + description: 単一アカウントの情報(ニックネームとアイコンのURL)を返す + parameters: + - in: path + name: user-id + description: 取得対象のユーザーID + schema: + type: string + required: true + responses: + '200': + description: Successful operation + content: + application/json: + schema: + type: object + properties: + name: + type: string + example: "nitta" + icon: + type: string + format: uri + example: "https://example.com/images/user-id1.png" + "400": + description: 不正なリクエスト + "404": + description: データが存在しません + "500": + description: 予期せぬエラー + # put: #削除予定 + # tags: + # - users + # summary: IDの変更 + # description: IDの変更 + # parameters: + # - $ref: "#/components/parameters/user-id" + # requestBody: + # required: true + # content: + # application/x-www-form-urlencoded: + # schema: + # type: object + # properties: + # token: + # type: string + # description: 認証トークン + # new_user-id: + # type: string + # description: 新しいID + # required: + # - token + # - new_user-id + # responses: + # '200': + # description: Successful operation + # content: + # application/json: + # schema: + # type: string + # example: atarashi_user-id1 + # '404': + # description: "見つかりませんでした" + + delete: #ゆなし + tags: + - "users" + summary: "アカウントの削除" + description: 単一アカウントの情報を削除する + parameters: + - in: path + name: user-id + description: 削除対象のユーザーID + schema: + type: string + required: true + - in: query + name: token + description: 削除対象ユーザーの認証トークン + schema: + type: string + required: true + responses: + '200': #成功 + description: 成功 + "400": + description: 不正なリクエスト + "401": + description: 未認証 + "403": + description: トークンの不一致 + "404": + description: データが存在しません + "500": + description: 予期せぬエラー + + /users/{user-id}/login: #いわたに + post: + tags: + - users + summary: アカウントのログイン処理 + description: アカウントにログインし、成功したら認証tokenを返す + parameters: + - in: path + name: user-id + description: ログインするユーザーのユーザーID + schema: + type: string + required: true + requestBody: + required: true + content: + application/x-www-form-urlencoded: + schema: + type: object + properties: + password: + type: string + description: パスワード + required: + - password + responses: + "200": + description: Successful operation + content: + application/json: + schema: + type: object + properties: + token: + type: string + example: Tsrt83hw3tG84tu1 + "401": + description: パスワード間違い + "404": + description: IDが存在しません + "400": + description: 不正なリクエスト + "500": + description: 予期せぬエラー + + /users/{user-id}/name: #ゆなし + get: + tags: + - "users" + summary: "アカウントのニックネームの取得" + description: 単一アカウントのニックネームを返す + parameters: + - in: path + name: user-id + description: 取得対象のユーザーID + schema: + type: string + required: true + responses: + '200': #成功 + description: 成功 + content: + application/json: + schema: + type: "string" + example: "にったなのだ" + "400": + description: 不正なリクエスト + "404": + description: データが存在しません + "500": + description: 予期せぬエラー + put: + tags: + - "users" + summary: "ニックネームの変更" + description: 単一アカウントのニックネームを変更する + parameters: + - in: path + name: user-id + description: 変更対象のユーザーID + schema: + type: string + required: true + requestBody: + required: true + content: + application/x-www-form-urlencoded: + schema: + type: object + properties: + token: + type: string + description: 認証トークン + new-name: + type: string + description: 新しいニックネーム + required: + - token + - new-name + responses: + '200': #成功 + description: 成功 + content: + application/json: + schema: + type: "string" + example: "にったんラブ" + "400": + description: 不正なリクエスト + "401": + description: 未認証 + "403": + description: トークンの不一致 + "404": + description: データが存在しません + "500": + description: 予期せぬエラー + /users/{user-id}/password: #いわたに + get: #実装の判断は任せる + tags: + - users + summary: 単一アカウントのパスワードの取得 + description: 単一アカウントの現在のパスワードの取得 + parameters: + - in: path + name: user-id + description: 取得対象のユーザーID + schema: + type: string + required: true + - in: query + name: token + description: 認証トークン + schema: + type: string + required: true + responses: + '200': + description: Successful operation + content: + applicaion/json: + schema: + type: object + properties: + password: + type: string + example: nittalab + "400": + description: 不正なリクエスト + "401": + description: 未認証 + "403": + description: トークンの不一致 + "404": + description: データが存在しません + "500": + description: 予期せぬエラー + put: + tags: + - users + summary: パスワードを変更する + description: 指定されたIDのパスワードを変更する + parameters: + - in: path + name: user-id + description: 変更対象のユーザーID + schema: + type: string + required: true + requestBody: + required: true + content: + application/x-www-form-urlencoded: + schema: + type: object + properties: + token: + type: string + description: トークン + new-password: + type: string + description: 新しいパスワード + required: + - new-password + - token + responses: + '200': + description: Successful operation + '401': + description: 変更前のパスワード間違い + '403': + description: 認証トークンエラー + '404': + description: "見つかりませんでした" + "400": + description: 不正なリクエスト + "500": + description: 予期せぬエラー + + /users/{user-id}/email: #いわたに + get: + tags: + - users + summary: 単一アカウントのemailの取得 + description: 単一アカウントの現在のemailの取得 + parameters: + - in: path + name: user-id + description: 取得対象のユーザーID + schema: + type: string + required: true + - in: query + name: token + description: 認証トークン + schema: + type: string + required: true + responses: + '200': + description: Successful operation + content: + applicaion/json: + schema: + type: object + properties: + email: + type: string + example: nittalab@gmail.com + '403': + description: 認証トークンエラー + '404': + description: IDが存在しません + "400": + description: 不正なリクエスト + "401": + description: 未認証 + "500": + description: 予期せぬエラー + put: + tags: + - users + summary: emailを変更する + description: 指定されたIDのemailを変更する + parameters: + - in: path + name: user-id + description: 変更対象のユーザーID + schema: + type: string + required: true + requestBody: + required: true + content: + application/x-www-form-urlencoded: + schema: + type: object + properties: + token: + type: string + description: トークン + new-email: + type: string + description: 新しいemail + + required: + - new-email + - token + responses: + '200': + description: Successful operarion + '403': + description: 認証トークンエラー + '404': + description: 見つかりませんでした + "400": + description: 不正なリクエスト + "401": + description: 未認証 + "409": + description: メールアドレスの重複 + "500": + description: 予期せぬエラー + + /users/{user-id}/icon: #たなか + get: + tags: # accountsタグの中のお話 + - users + summary: アイコンを返す + description: 指定されたIDのアイコンのURLを返す + parameters: + - in: path + name: user-id + description: 取得対象のユーザーID + schema: + type: string + required: true + responses: + "200": + description: Successsful operation + content: + application/json: + schema: + type: string + format: uri + example: "https://example.com/images/bacon.png" + "400": + description: 不正なリクエスト + "404": + description: データが存在しません + "500": + description: 予期せぬエラー + put: + tags: + - users + summary: アイコンを変更する + description: 指定されたIDのアイコンを変更する + parameters: + - in: path + name: user-id + description: 変更対象のユーザーID + schema: + type: string + required: true + requestBody: + required: true + content: + application/x-www-form-urlencoded: + schema: + type: object + properties: + token: + type: string + description: 認証トークン + new-icon: + type: string + description: 新しい画像(base64) + required: + - token + - new-icon + responses: + "200": + description: Successsfil operation + content: + applicaion/json: + schema: + type: object + properties: + icon: + type: string + example: "66F8B439D11A76CA" + "400": + description: 不正なリクエスト + "401": + description: 未認証 + "403": + description: トークンの不一致 + "404": + description: データが存在しません + "500": + description: 予期せぬエラー + + #アクティビティの情報 #ゆなし + /users/{user-id}/activities: + get: + tags: + - "users/{user-id}/activities" + summary: アカウントの全アクティビティの取得 + description: ユーザーIDで指定したアカウントの全アクティビティを取得する(フィルターで最新の投稿のみの取得) + parameters: + - in: path + name: user-id + description: 取得対象のユーザーID + schema: + type: string + required: true + - in: query + name: filter + description: "LATEST: 最新のみ取得" + schema: + type: string + required: false + responses: + '200': #成功 + description: 成功 + content: + application/json: + schema: + type: "object" + properties: + activity-id1: + type: "object" + properties: + text: + type: "string" + example: "今暇やねん" + updated-time: + type: "string" + example: "2025/05/14 15:20" + activity-id2: + type: "object" + properties: + text: + type: "string" + example: "お風呂入ってたわ" + updated-time: + type: "string" + example: "2025/05/14 23:50" + "400": + description: 不正なリクエスト + "404": + description: データが存在しません + "500": + description: 予期せぬエラー + post: + tags: + - "users/{user-id}/activities" + summary: 新規アクティビティの投稿 + description: 指定したアカウントで新規のアクティビティを投稿する。成功したら作成したアクティビティのIDを返す。 + parameters: + - in: path + name: user-id + description: 投稿するユーザーのユーザーID + schema: + type: string + required: true + requestBody: + required: true + content: + application/x-www-form-urlencoded: # この形式のデータを使ってパスワードを変更 + schema: + type: object + properties: + token: + type: string + description: 認証トークン + new-activity: + type: string + description: 新しいアクティビティのテキスト + required: + - token + - new-activity + responses: + '200': #成功 + description: 成功 + content: + application/json: + schema: + properties: + activity-id: + type: "string" + example: "fneit8" + "400": + description: 不正なリクエスト + "401": + description: 未認証 + "403": + description: トークンの不一致 + "404": + description: データが存在しません + "500": + description: 予期せぬエラー + + /users/{user-id}/activities/{activity-id}: + get: + tags: + - "users/{user-id}/activities" + summary: アカウントの単一アクティビティ取得 + description: アクティビティIDを指定して、アカウントの単一アクティビティを取得する + parameters: + - in: path + name: user-id + description: 取得対象のユーザーID + schema: + type: string + required: true + - in: path + name: activity-id + description: 取得対象のアクティビティID + schema: + type: string + required: true + responses: + '200': #成功 + description: 成功 + content: + application/json: + schema: + type: "object" + properties: + activity-id: + type: "string" + example: "ajejg5" + text: + type: "string" + example: "にったんに会った" + updated-time: + type: "string" + example: "2025/05/14 15:30" + "400": + description: 不正なリクエスト + "404": + description: データが存在しません + "500": + description: 予期せぬエラー + + delete: + tags: + - "users/{user-id}/activities" + summary: "アクティビティの削除" + description: "アカウントの単一アクティビティを削除する" + parameters: + - in: path + name: user-id + description: 削除対象のユーザーID + schema: + type: string + required: true + - in: path + name: activity-id + description: 削除対象のアクティビティID + schema: + type: string + required: true + - in: query + name: token + description: 認証トークン + schema: + type: string + required: true + responses: + '200': #成功 + description: 成功 + "400": + description: 不正なリクエスト + "401": + description: 未認証 + "403": + description: トークンの不一致 + "404": + description: データが存在しません + "500": + description: 予期せぬエラー + + /users/{user-id}/activities/{activity-id}/text: + get: #実装は任せる + tags: + - "users/{user-id}/activities" + summary: "アカウントのアクティビティの文章" + description: "指定したアカウントの指定したアクティビティの文章の内容を取得する" + parameters: + - in: path + name: user-id + description: 取得対象のユーザーID + schema: + type: string + required: true + - in: path + name: activity-id + description: 取得対象のアクティビティID + schema: + type: string + required: true + responses: + '200': #成功 + description: 成功 + content: + application/json: + schema: + type: "string" + example: "今起きた" + "400": + description: 不正なリクエスト + "404": + description: データが存在しません + "500": + description: 予期せぬエラー + + /users/{user-id}/activities/{activity-id}/updated-time: + get: #実装は任せる + tags: + - "users/{user-id}/activities" + summary: "単一アクティビティの投稿時間" + description: "指定したアカウントの指定したアクティビティの投稿時間を取得する" + parameters: + - in: path + name: user-id + description: 取得対象のユーザーID + schema: + type: string + required: true + - in: path + name: activity-id + description: 取得対象のアクティビティID + schema: + type: string + required: true + responses: + '200': #成功 + description: 成功 + content: + application/json: + schema: + type: "string" + example: "2025/05/14 01:00" + "400": + description: 不正なリクエスト + "404": + description: データが存在しません + "500": + description: 予期せぬエラー + + /users/{user-id}/activities/last-updated-time: + get: + tags: + - "users/{user-id}/activities" + summary: "最新アクティビティの投稿時間" + description: "指定したアカウントの最新のアクティビティの投稿時間を取得する" + parameters: + - in: path + name: user-id + description: 取得対象のユーザーID + schema: + type: string + required: true + responses: + '200': #成功 + description: 成功 + content: + application/json: + schema: + type: "string" + example: "2025/05/14 01:00" + '404': + description: データが存在しません(まだ投稿していない) + "400": + description: 不正なリクエスト + "500": + description: 予期せぬエラー + + # put: #削除か非公開予定 + # tags: + # - "users/{user-id}/activities" + # summary: "投稿時間の更新" + # description: アクティビティの投稿時間を更新する + # parameters: + # - $ref: "#/components/parameters/user-id" + # requestBody: + # required: true + # content: + # application/x-www-form-urlencoded: + # schema: + # type: object + # properties: + # token: + # type: string + # description: 認証トークン + # new_updated-time: + # type: string + # description: 新しいアクティビティの投稿時間 + # required: + # - token + # - new_updated-time + # responses: + # '200': #成功 + # description: 成功 + # content: + # application/json: + # schema: + # type: "string" + # example: "2025/05/14 14:25" + # '404': + # description: IDが存在しません + + + #フレンド関係の情報 #よしむらくん + /users/{user-id}/friends: + get: + tags: + - users/{user-id}/friends + summary: 自分のフレンドペアのペアIDの一覧(JSON)の取得 + description: 指定したアカウントが所属しているフレンドペアの、ペアIDから各ユーザーIDへのマップ(JSON)の取得 + parameters: + - in: path + name: user-id + description: 取得対象のユーザーID + schema: + type: string + required: true + - in: query + name: token + description: 認証トークン + schema: + type: string + required: true + responses: + '200': + description: 成功 + content: + application/json: + schema: + type: object + properties: + pid1: + type: object + properties: + user0-id: + type: string + example: oh3rhowgy3 + user1-id: + type: string + example: w3485nwv84 + pid2: + type: object + properties: + user0-id: + type: string + example: oh3rhowgy3 + user1-id: + type: string + example: l45yn39w5v9 + "400": + description: 不正なリクエスト + "401": + description: 未認証 + "403": + description: トークンの不一致 + "404": + description: データが存在しません + "500": + description: 予期せぬエラー + + # post: #非公開予定 + # tags: + # - users/{user-id}/friends + # summary: 新規ペアの追加 + # description: 新規ペアを追加するためのエンドポイント + # parameters: + # - $ref: "#/components/parameters/user-id" + # requestBody: + # required: true + # content: + # application/x-www-form-urlencoded: + # schema: + # type: object + # properties: + # token: + # type: string + # description: 認証トークン + # pair-id: + # type: string + # description: フレンドのペアID + # user1_id: + # type: string + # description: ペアの1人目のユーザーID + # example: user-id123 + # user2_id: + # type: string + # description: ペアの2人目のユーザーID + # example: user-id456 + # required: + # - token + # - pair-id + # - user1_id + # - user2_id + # responses: + # '200': + # description: 成功 + # content: + # application/json: + # schema: + # type: object + # properties: + # pair_id: + # type: string + # description: 作成されたペアのID + # example: pid789 + + /users/{user-id}/friends/{pair-id}: + get: #実装お任せ + tags: + - users/{user-id}/friends + summary: フレンド相手の情報の取得 + description: 指定したアカウントの指定したフレンドペアの相手のユーザー ID の取得 + parameters: + - in: path + name: user-id + description: 取得能動側のユーザーID + schema: + type: string + required: true + - in: path + name: pair-id + description: フレンドのペアID + schema: + type: string + required: true + - in: query + name: token + description: 認証トークン + schema: + type: string + required: true + responses: + '200': + description: 成功 + content: + application/json: + schema: + type: object + properties: + user-id: + type: string + description: ペアのユーザーID + example: 相手のuser-id + "400": + description: 不正なリクエスト + "401": + description: 未認証 + "403": + description: トークンの不一致 + "404": + description: データが存在しません + "500": + description: 予期せぬエラー + delete: + tags: + - users/{user-id}/friends + summary: フレンドペアの削除 + description: 指定したフレンドペアの削除 + parameters: + - in: path + name: user-id + description: 削除能動側のユーザーID + schema: + type: string + required: true + - in: path + name: pair-id + description: フレンドのペアID + schema: + type: integer + required: true + - in: query + name: token + description: 認証トークン + schema: + type: string + required: true + responses: + '200': + description: 成功 + "400": + description: 不正なリクエスト + "401": + description: 未認証 + "403": + description: トークンの不一致 + "404": + description: データが存在しません + "500": + description: 予期せぬエラー + + + /friend-requests: + get: + tags: + - friend-requests + summary: 指定したユーザに関連するフレンドリクエストを返す + description: トークンによって指定されたユーザに関連するフレンドリクエストのみを返す(他人の情報を返さないように実装する) + parameters: + - in: query + name: token + description: 対象ユーザの認証用のトークン + example: d6289334-d2df-41bb-9410-d2f33de40b16 + required: true + schema: + type: string + responses: + "200": + description: すべてのフレンドリクエストを返す + content: + application/json: + schema: + type: array + items: + type: object + properties: + id: + type: integer + example: 12 + senderId: + type: string + example: "test1" + receiverId: + type: string + example: "test2" + "400": + description: 不正なリクエストです + "401": + description: トークンが無効です + "403": + description: 権限がありません + "404": + description: データが存在しません + "409": + description: データが重複しています + "500": + description: サーバー内部でエラーが発生しました + + post: + tags: + - friend-requests + summary: フレンドリクエストを作成 + description: トークンを使って新しいフレンドリクエストを作成する。成功したら作成したフレンドリクエストの ID を返す。 + requestBody: + required: true + content: + application/x-www-form-urlencoded: + schema: + type: object + properties: + token: + type: string + description: フレンドリクエストを送ったユーザーのトークン + example: d6289334-d2df-41bb-9410-d2f33de40b16 + sender-id: + type: string + description: フレンドリクエストを送ったユーザーのID + example: skyfox_82z + receiver-id: + type: string + description: フレンドリクエストを受け取るユーザーのID + example: echo_wolf7 + required: + - token + - sender-id + - receiver-id + responses: + "201": + description: "フレンドリクエストが作成されました" + content: + application/json: + schema: + type: string + format: uri + example: "24" + + "400": + description: "不正なリクエスト" + + /friend-requests/{friend-request-id}: + delete: + tags: + - friend-requests + summary: フレンドリクエストを削除 + description: フレンドリクエスト ID を指定してフレンドリクエストを削除 + parameters: + - in: path + name: friend-request-id + description: フレンドリクエストのID + required: true + example: 12 + schema: + type: integer + - in: query + name: receiver-token + description: リクエストを受け付けたユーザーの認証用トークン + example: d6289334-d2df-41bb-9410-d2f33de40b16 + required: true + schema: + type: string + responses: + "200": + description: "フレンドリクエストの削除に成功しました" + "404": + description: "指定されたIDのフレンドリクエストが見つかりませんでした" + + /friends/: + post: + tags: + - friends + summary: フレンドのペアを追加 + description: フレンドリクエストが承認されたときに呼び出し、フレンドペアが正常に追加されたら、ペアIDを返す + requestBody: + required: true + content: + application/x-www-form-urlencoded: + schema: + type: object + properties: + token: + type: string + description: フレンドリクエストを承認したユーザーのトークン + example: d6289334-d2df-41bb-9410-d2f33de40b16 + user0-id: + type: string + description: ユーザーID + example: skyfox_82z + user1-id: + type: string + description: ユーザーID + example: echo_wolf7 + required: + - token + - user0-id + - user1-id + responses: + "200": + description: 正常に処理できた + content: + application/json: + schema: + type: object + properties: + pair-id: + type: integer + example: 1 + "400": + description: 不正なリクエスト + "401": + description: トークンが無効 + "403": + description: 権限なし + "404": + description: データが存在しない + "409": + description: 重複している + "500": + description: エラー + + /friends/pairs/{pair-id}/: + parameters: + - in: path + name: pair-id + description: フレンドリクエストのペアID + required: true + schema: + type: integer + get: + tags: + - friends + summary: フレンドのペアを取得する + description: ペアIDを指定して、所属しているユーザのユーザIDを取得する + parameters: + - in: query + name: token + description: ペアのいずれかのユーザーの認証用トークン + example: d6289334-d2df-41bb-9410-d2f33de40b16 + required: true + schema: + type: string + responses: + "200": + description: ペアのリソースが存在したらそのリソースを返す + content: + application/json: + schema: + type: object + properties: + id: + type: string + description: ペアID + example: 13 + user0id: + type: string + description: ユーザーID + example: echo_wolf7 + user1Id: + type: string + description: ユーザーID + example: echo_wolf7 + "400": + description: 削除が失敗したとき + delete: + tags: + - friends + summary: フレンドのペアを削除 + description: ペアのいずれかのユーザーの認証用トークンを指定して、フレンドペアを削除する + parameters: + - in: query + name: token + description: ペアのいずれかのユーザーの認証用トークン + example: d6289334-d2df-41bb-9410-d2f33de40b16 + required: true + schema: + type: string + responses: + "200": + description: 削除が成功したとき + "400": + description: 不正なリクエスト + "401": + description: トークンが無効 + "403": + description: 権限なし + "404": + description: データが存在しない + "409": + description: 重複している + "500": + description: エラー + + /friends/users/{user-id}: + get: + tags: + - friends + summary: 自分のフレンド一覧の取得 + description: 指定したユーザのフレンド一覧を、ユーザIDのリストとして返す + parameters: + - in: path + name: user-id + description: 取得対象のユーザーID + schema: + type: string + required: true + - in: query + name: token + description: 認証トークン + schema: + type: string + required: true + responses: + '200': + description: Successful operation + content: + applicaion/json: + schema: + type: array + items: + type: string + example: + - "user-id1" + - "user-id2" + - "user-id3" + "400": + description: 不正なリクエスト + "401": + description: 未認証 + "403": + description: トークンの不一致 + "404": + description: データが存在しません + "500": + description: 予期せぬエラー + + /chat-requests/: + post: + tags: + - chat-requests + summary: チャットリクエストの作成 + description: トークンを使って他人に成りすましたチャットリクエストを作成しないように実装する(ユーザー自身からのチャットリクエストのみを作成する)。成功したら作成したチャットリクエストのIDを返す。 + requestBody: + required: true + content: + application/x-www-form-urlencoded: + schema: + type: object + properties: + token: + type: string + description: 認証用のトークン + example: d6289334-d2df-41bb-9410-d2f33de40b16 + sender-id: + type: string + description: リクエストした側のユーザID + example: skyfox_82z + receiver-id: + type: string + description: リクエストされた側のユーザID + example: echo_wolf7 + required: + - token + - sender-id + - receiver-id + responses: + "204": + description: チャットがリクエストされました。 + content: + application/json: + schema: + type: object + properties: + chat-request-id: + type: integer + description: 作成されたチャットリクエストのID + example: 20 + + /chat-requests/{chat-request-id}/: + delete: + tags: + - chat-requests + summary: チャットのリクエストを消去する + description: チャットリクエストIDを指定してチャットリクエストを消去する + parameters: + - in: path + name: chat-request-id + example: 20 + schema: + type: integer + required: true + - in: query + name: token + example: d6289334-d2df-41bb-9410-d2f33de40b16 + schema: + type: string + required: true + responses: + "204": + description: チャットリクエストが削除されました。 + "401": + description: 認証が必要です + "403": + description: 権限がありません。 + "404": + description: チャットリクエストが見つかりません。 + + /chat-rooms/: + post: + tags: + - chat-rooms + summary: チャットルームの作成 + description: チャットリクエストの承認時に呼び出され、リクエストした側のユーザとされた側のユーザーがチャットルームに入る。成功したら、作成したチャットルームのIDを返す。 + parameters: + - in: query + name: user0-id + example: user0-id + schema: + type: string + required: true + - in: query + name: user1-id + example: user1-id + schema: + type: string + required: true + - in: query + name: token + description: user0-id側のトークン + example: d6289334-d2df-41bb-9410-d2f33de40b16 + schema: + type: string + required: true + responses: + "200": + description: 成功時のレスポンス + content: + application/json: + schema: + type: object + properties: + room-id: + type: integer + example: 1 + "401": + description: 認証失敗 + get: + tags: + - chat-rooms + summary: チャットルームのIDの取得 + description: 指定したユーザが参加しているチャットルームを検索して、チャットルームIDを取得する + parameters: + - in: query + name: user0-id + example: user0-id + schema: + type: string + required: true + - in: query + name: token + description: user0-idのトークン + example: d6289334-d2df-41bb-9410-d2f33de40b16 + schema: + type: string + required: true + responses: + "200": + description: 成功時のレスポンス + content: + application/json: + schema: + type: object + properties: + room-id: + type: integer + example: 1 + "404": + description: IDが存在しません + "401": + description: 認証失敗 + + /chat-rooms/{chatroom-id}/{user-id}/: + get: + tags: + - chat-rooms + summary: メッセージを閲覧する + description: チャットルームIDと相手のユーザのIDを指定して、相手のチャットメッセージを取得する。 + parameters: + - in: path + name: chatroom-id + required: true + description: チャットルームのID + schema: + type: integer + - in: path + name: user-id + required: true + description: 相手のユーザーID + example: skyfox_82z + schema: + type: string + - in: query + name: token + example: d6289334-d2df-41bb-9410-d2f33de40b16 + required: true + description: チャットルームに入っているユーザーの認証用トークン + schema: + type: string + responses: + "200": + description: 成功 + content: + application/json: + schema: + type: object + properties: + message: + type: string + description: メッセージ本文 + example: "この後ご飯行かんー?" + "403": + description: "認証されていません" + delete: + tags: + - chat-rooms + summary: チャットルームの削除 + description: チャットルームIDを指定して、チャットルームを削除する + parameters: + - in: path + name: chatroom-id + example: 20 + schema: + type: integer + required: true + - in: path + name: user-id + example: test + schema: + type: string + required: true + - in: query + name: token + example: d6289334-d2df-41bb-9410-d2f33de40b16 + schema: + type: string + required: true + responses: + "200": + description: 成功 + content: + application/json: + schema: + type: object + properties: + message: + type: string + description: メッセージ本文 + example: "ユーザをルームから退出しました" + "204": + description: チャットルームidが見つかりません。 + "401": + description: IDが存在しません。 + "404": + description: チャットリクエストが見つかりません。 + put: + tags: + - chat-rooms + summary: チャットルームにユーザーを追加する + description: チャットルームにユーザーを追加する(メッセージは作成しない) + parameters: + - in: path + name: chatroom-id + required: true + description: チャットルームのID + example: 12 + schema: + type: integer + - in: path + name: user-id + required: true + description: チャットルームに参加するユーザーのID + example: skyfox_82z + schema: + type: string + - in: query + name: token + required: true + description: チャットルームに参加するユーザーの認証用のトークン + example: d6289334-d2df-41bb-9410-d2f33de40b16 + schema: + type: string + responses: + "200": + description: 参加に成功しました + "403": + description: 認証されていません + "404": + description: チャットルームが見つかりません + "500": + description: サーバー内部でエラーが発生しました + + + /chat-rooms/{chatroom-id}/{user-id}/message: + # parameters: + # - $ref: "#/components/parameters/chat-room-id" + # - $ref: "#/components/parameters/user-id" + put: + tags: + - chat-rooms + summary: メッセージの更新 + description: 自分のチャットメッセージを更新する。 + parameters: + - in: path + name: user-id + description: ユーザーID + schema: + type: string + required: true + - in: path + name: chatroom-id + description: チャットルームID + schema: + type: string + required: true + requestBody: + required: true + content: + application/x-www-form-urlencoded: + schema: + type: object + properties: + token: + type: string + description: user-idのトークン + message: + type: string + description: 新しいメッセージ + required: + - message + - token + responses: + "200": + description: 正常にメッセージが更新されました + "400": + description: リクエスト形式が不正です + "404": + description: チャットルームが見つかりません + "500": + description: サーバー内部でエラーが発生しました +# components: + + + \ No newline at end of file