openapi: 3.0.0 info: title: 5ch風掲示板API description: 5ch風掲示板アプリケーションのREST API仕様書 version: 1.0.0 contact: name: API Support email: support@example.com license: name: MIT servers: - url: http://localhost:3001/api description: 開発環境 - url: https://api.example.com/api description: 本番環境 paths: # ============================================ # 認証エンドポイント # ============================================ /auth/register: post: summary: ユーザー登録 tags: - Authentication requestBody: required: true content: application/json: schema: type: object required: - username - email - password properties: username: type: string minLength: 3 maxLength: 50 example: john_doe email: type: string format: email example: john@example.com password: type: string minLength: 8 format: password example: SecurePassword123 responses: '201': description: ユーザー登録成功 content: application/json: schema: type: object properties: status: type: string example: success message: type: string example: ユーザー登録が完了しました data: $ref: '#/components/schemas/User' '400': $ref: '#/components/responses/BadRequest' '409': $ref: '#/components/responses/Conflict' /auth/login: post: summary: ログイン tags: - Authentication requestBody: required: true content: application/json: schema: type: object required: - email - password properties: email: type: string format: email example: john@example.com password: type: string format: password example: SecurePassword123 responses: '200': description: ログイン成功 content: application/json: schema: type: object properties: status: type: string example: success message: type: string example: ログインしました data: type: object properties: token: type: string example: eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9... user: $ref: '#/components/schemas/User' '400': $ref: '#/components/responses/BadRequest' '401': $ref: '#/components/responses/Unauthorized' /auth/logout: post: summary: ログアウト tags: - Authentication security: - bearerAuth: [] responses: '200': description: ログアウト成功 content: application/json: schema: type: object properties: status: type: string example: success message: type: string example: ログアウトしました '401': $ref: '#/components/responses/Unauthorized' /auth/refresh: post: summary: トークン更新 tags: - Authentication security: - bearerAuth: [] responses: '200': description: トークン更新成功 content: application/json: schema: type: object properties: status: type: string example: success data: type: object properties: token: type: string example: eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9... '401': $ref: '#/components/responses/Unauthorized' # ============================================ # スレッドエンドポイント # ============================================ /threads: get: summary: スレッド一覧取得 tags: - Threads parameters: - name: page in: query description: ページ番号 schema: type: integer default: 1 - name: limit in: query description: 1ページあたりの件数 schema: type: integer default: 20 maximum: 100 - name: category in: query description: カテゴリID schema: type: integer - name: sort in: query description: ソート順(recent, popular, comments) schema: type: string enum: [recent, popular, comments] default: recent - name: search in: query description: キーワード検索 schema: type: string responses: '200': description: スレッド一覧取得成功 content: application/json: schema: type: object properties: status: type: string example: success data: type: array items: $ref: '#/components/schemas/Thread' pagination: $ref: '#/components/schemas/Pagination' '400': $ref: '#/components/responses/BadRequest' post: summary: スレッド作成 tags: - Threads security: - bearerAuth: [] requestBody: required: true content: application/json: schema: type: object required: - title - categoryId properties: title: type: string minLength: 1 maxLength: 255 example: 新しいスレッド categoryId: type: integer example: 1 description: type: string maxLength: 1000 example: スレッドの説明 responses: '201': description: スレッド作成成功 content: application/json: schema: type: object properties: status: type: string example: success data: $ref: '#/components/schemas/Thread' '400': $ref: '#/components/responses/BadRequest' '401': $ref: '#/components/responses/Unauthorized' /threads/{threadId}: get: summary: スレッド詳細取得 tags: - Threads parameters: - name: threadId in: path required: true schema: type: integer responses: '200': description: スレッド詳細取得成功 content: application/json: schema: type: object properties: status: type: string example: success data: $ref: '#/components/schemas/Thread' '404': $ref: '#/components/responses/NotFound' delete: summary: スレッド削除 tags: - Threads security: - bearerAuth: [] parameters: - name: threadId in: path required: true schema: type: integer responses: '200': description: スレッド削除成功 content: application/json: schema: type: object properties: status: type: string example: success message: type: string example: スレッドを削除しました '403': $ref: '#/components/responses/Forbidden' '404': $ref: '#/components/responses/NotFound' # ============================================ # 投稿エンドポイント # ============================================ /posts: get: summary: 投稿一覧取得 tags: - Posts parameters: - name: threadId in: query required: true description: スレッドID schema: type: integer - name: page in: query description: ページ番号 schema: type: integer default: 1 - name: limit in: query description: 1ページあたりの件数 schema: type: integer default: 20 maximum: 100 responses: '200': description: 投稿一覧取得成功 content: application/json: schema: type: object properties: status: type: string example: success data: type: array items: $ref: '#/components/schemas/Post' pagination: $ref: '#/components/schemas/Pagination' '400': $ref: '#/components/responses/BadRequest' post: summary: 投稿作成 tags: - Posts security: - bearerAuth: [] requestBody: required: true content: application/json: schema: type: object required: - threadId - content properties: threadId: type: integer example: 1 content: type: string minLength: 1 maxLength: 5000 example: 投稿内容 responses: '201': description: 投稿作成成功 content: application/json: schema: type: object properties: status: type: string example: success data: $ref: '#/components/schemas/Post' '400': $ref: '#/components/responses/BadRequest' '401': $ref: '#/components/responses/Unauthorized' /posts/{postId}: get: summary: 投稿詳細取得 tags: - Posts parameters: - name: postId in: path required: true schema: type: integer responses: '200': description: 投稿詳細取得成功 content: application/json: schema: type: object properties: status: type: string example: success data: $ref: '#/components/schemas/Post' '404': $ref: '#/components/responses/NotFound' put: summary: 投稿編集 tags: - Posts security: - bearerAuth: [] parameters: - name: postId in: path required: true schema: type: integer requestBody: required: true content: application/json: schema: type: object required: - content properties: content: type: string minLength: 1 maxLength: 5000 example: 編集された投稿内容 responses: '200': description: 投稿編集成功 content: application/json: schema: type: object properties: status: type: string example: success data: $ref: '#/components/schemas/Post' '400': $ref: '#/components/responses/BadRequest' '403': $ref: '#/components/responses/Forbidden' '404': $ref: '#/components/responses/NotFound' delete: summary: 投稿削除 tags: - Posts security: - bearerAuth: [] parameters: - name: postId in: path required: true schema: type: integer responses: '200': description: 投稿削除成功 content: application/json: schema: type: object properties: status: type: string example: success message: type: string example: 投稿を削除しました '403': $ref: '#/components/responses/Forbidden' '404': $ref: '#/components/responses/NotFound' # ============================================ # ユーザーエンドポイント # ============================================ /users: get: summary: ユーザー検索 tags: - Users parameters: - name: search in: query required: true description: ユーザー名検索 schema: type: string - name: page in: query description: ページ番号 schema: type: integer default: 1 - name: limit in: query description: 1ページあたりの件数 schema: type: integer default: 20 responses: '200': description: ユーザー検索成功 content: application/json: schema: type: object properties: status: type: string example: success data: type: array items: $ref: '#/components/schemas/User' pagination: $ref: '#/components/schemas/Pagination' '400': $ref: '#/components/responses/BadRequest' /users/{userId}: get: summary: ユーザープロフィール取得 tags: - Users parameters: - name: userId in: path required: true schema: type: integer responses: '200': description: ユーザープロフィール取得成功 content: application/json: schema: type: object properties: status: type: string example: success data: $ref: '#/components/schemas/UserProfile' '404': $ref: '#/components/responses/NotFound' put: summary: ユーザープロフィール更新 tags: - Users security: - bearerAuth: [] parameters: - name: userId in: path required: true schema: type: integer requestBody: required: true content: application/json: schema: type: object properties: username: type: string minLength: 3 maxLength: 50 bio: type: string maxLength: 500 profileImage: type: string format: binary responses: '200': description: プロフィール更新成功 content: application/json: schema: type: object properties: status: type: string example: success data: $ref: '#/components/schemas/UserProfile' '400': $ref: '#/components/responses/BadRequest' '403': $ref: '#/components/responses/Forbidden' '404': $ref: '#/components/responses/NotFound' delete: summary: ユーザーアカウント削除 tags: - Users security: - bearerAuth: [] parameters: - name: userId in: path required: true schema: type: integer responses: '200': description: アカウント削除成功 content: application/json: schema: type: object properties: status: type: string example: success message: type: string example: アカウントを削除しました '403': $ref: '#/components/responses/Forbidden' '404': $ref: '#/components/responses/NotFound' # ============================================ # フォローエンドポイント # ============================================ /follows: post: summary: ユーザーをフォロー tags: - Follows security: - bearerAuth: [] requestBody: required: true content: application/json: schema: type: object required: - followingId properties: followingId: type: integer example: 2 responses: '201': description: フォロー成功 content: application/json: schema: type: object properties: status: type: string example: success message: type: string example: フォローしました '400': $ref: '#/components/responses/BadRequest' '401': $ref: '#/components/responses/Unauthorized' /follows/{followingId}: delete: summary: ユーザーをアンフォロー tags: - Follows security: - bearerAuth: [] parameters: - name: followingId in: path required: true schema: type: integer responses: '200': description: アンフォロー成功 content: application/json: schema: type: object properties: status: type: string example: success message: type: string example: フォローを解除しました '401': $ref: '#/components/responses/Unauthorized' '404': $ref: '#/components/responses/NotFound' # ============================================ # メッセージエンドポイント # ============================================ /messages: get: summary: メッセージスレッド一覧取得 tags: - Messages security: - bearerAuth: [] parameters: - name: page in: query description: ページ番号 schema: type: integer default: 1 - name: limit in: query description: 1ページあたりの件数 schema: type: integer default: 20 responses: '200': description: メッセージスレッド一覧取得成功 content: application/json: schema: type: object properties: status: type: string example: success data: type: array items: $ref: '#/components/schemas/MessageThread' pagination: $ref: '#/components/schemas/Pagination' '401': $ref: '#/components/responses/Unauthorized' post: summary: メッセージ送信 tags: - Messages security: - bearerAuth: [] requestBody: required: true content: application/json: schema: type: object required: - receiverId - content properties: receiverId: type: integer example: 2 content: type: string minLength: 1 maxLength: 5000 example: メッセージ内容 responses: '201': description: メッセージ送信成功 content: application/json: schema: type: object properties: status: type: string example: success data: $ref: '#/components/schemas/Message' '400': $ref: '#/components/responses/BadRequest' '401': $ref: '#/components/responses/Unauthorized' /messages/{threadId}: get: summary: メッセージスレッド詳細取得 tags: - Messages security: - bearerAuth: [] parameters: - name: threadId in: path required: true schema: type: integer - name: page in: query description: ページ番号 schema: type: integer default: 1 - name: limit in: query description: 1ページあたりの件数 schema: type: integer default: 20 responses: '200': description: メッセージスレッド詳細取得成功 content: application/json: schema: type: object properties: status: type: string example: success data: type: array items: $ref: '#/components/schemas/Message' pagination: $ref: '#/components/schemas/Pagination' '401': $ref: '#/components/responses/Unauthorized' '404': $ref: '#/components/responses/NotFound' /messages/{messageId}: delete: summary: メッセージ削除 tags: - Messages security: - bearerAuth: [] parameters: - name: messageId in: path required: true schema: type: integer responses: '200': description: メッセージ削除成功 content: application/json: schema: type: object properties: status: type: string example: success message: type: string example: メッセージを削除しました '401': $ref: '#/components/responses/Unauthorized' '403': $ref: '#/components/responses/Forbidden' '404': $ref: '#/components/responses/NotFound' # ============================================ # ヘルスチェック # ============================================ /health: get: summary: ヘルスチェック tags: - Health responses: '200': description: ヘルスチェック成功 content: application/json: schema: type: object properties: status: type: string example: ok timestamp: type: string format: date-time example: '2026-07-26T12:00:00Z' components: schemas: User: type: object properties: id: type: integer example: 1 username: type: string example: john_doe email: type: string format: email example: john@example.com createdAt: type: string format: date-time example: '2026-07-26T12:00:00Z' updatedAt: type: string format: date-time example: '2026-07-26T12:00:00Z' UserProfile: allOf: - $ref: '#/components/schemas/User' - type: object properties: bio: type: string example: ユーザーの紹介文 profileImage: type: string format: uri example: https://example.com/profiles/1.jpg threadCount: type: integer example: 10 postCount: type: integer example: 50 followerCount: type: integer example: 100 followingCount: type: integer example: 50 Thread: type: object properties: id: type: integer example: 1 title: type: string example: スレッドタイトル description: type: string example: スレッドの説明 categoryId: type: integer example: 1 categoryName: type: string example: 雑談 createdBy: type: integer example: 1 createdByName: type: string example: john_doe postCount: type: integer example: 10 lastPostAt: type: string format: date-time example: '2026-07-26T12:00:00Z' createdAt: type: string format: date-time example: '2026-07-26T12:00:00Z' updatedAt: type: string format: date-time example: '2026-07-26T12:00:00Z' Post: type: object properties: id: type: integer example: 1 threadId: type: integer example: 1 content: type: string example: 投稿内容 createdBy: type: integer example: 1 createdByName: type: string example: john_doe editedAt: type: string format: date-time example: '2026-07-26T12:00:00Z' createdAt: type: string format: date-time example: '2026-07-26T12:00:00Z' MessageThread: type: object properties: id: type: integer example: 1 otherUserId: type: integer example: 2 otherUserName: type: string example: jane_doe lastMessageContent: type: string example: 最後のメッセージ内容 unreadCount: type: integer example: 3 lastMessageAt: type: string format: date-time example: '2026-07-26T12:00:00Z' Message: type: object properties: id: type: integer example: 1 senderId: type: integer example: 1 senderName: type: string example: john_doe receiverId: type: integer example: 2 content: type: string example: メッセージ内容 isRead: type: boolean example: true createdAt: type: string format: date-time example: '2026-07-26T12:00:00Z' Pagination: type: object properties: page: type: integer example: 1 limit: type: integer example: 20 total: type: integer example: 100 pages: type: integer example: 5 Error: type: object properties: status: type: string example: error code: type: string example: INVALID_REQUEST message: type: string example: リクエストが不正です details: type: object example: field: email error: メールアドレスが不正です timestamp: type: string format: date-time example: '2026-07-26T12:00:00Z' responses: BadRequest: description: 不正なリクエスト(400) content: application/json: schema: $ref: '#/components/schemas/Error' Unauthorized: description: 認証が必要です(401) content: application/json: schema: $ref: '#/components/schemas/Error' Forbidden: description: アクセス権限がありません(403) content: application/json: schema: $ref: '#/components/schemas/Error' NotFound: description: リソースが見つかりません(404) content: application/json: schema: $ref: '#/components/schemas/Error' Conflict: description: リソースが既に存在します(409) content: application/json: schema: $ref: '#/components/schemas/Error' securitySchemes: bearerAuth: type: http scheme: bearer bearerFormat: JWT description: JWT認証トークン security: [] tags: - name: Authentication description: 認証関連のエンドポイント - name: Threads description: スレッド関連のエンドポイント - name: Posts description: 投稿関連のエンドポイント - name: Users description: ユーザー関連のエンドポイント - name: Follows description: フォロー関連のエンドポイント - name: Messages description: メッセージ関連のエンドポイント - name: Health description: ヘルスチェック externalDocs: description: API ドキュメント url: https://docs.example.com