{ "openapi": "3.1.0", "info": { "title": "Jyogi Navi API", "version": "0.1.0" }, "paths": { "/health": { "get": { "tags": [ "health" ], "summary": "Health Check", "description": "サービスの死活監視エンドポイント。", "operationId": "health_check_health_get", "responses": { "200": { "description": "Successful Response", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/HealthResponse" } } } } } } }, "/api/auth/login": { "get": { "tags": [ "auth" ], "summary": "Login", "description": "Discord OAuth 認可画面にリダイレクトする。", "operationId": "login_api_auth_login_get", "responses": { "200": { "description": "Successful Response", "content": { "application/json": { "schema": {} } } } } } }, "/api/auth/callback": { "get": { "tags": [ "auth" ], "summary": "Callback", "description": "Discord OAuth コールバック。トークンを交換してセッション Cookie を発行する。", "operationId": "callback_api_auth_callback_get", "parameters": [ { "name": "code", "in": "query", "required": true, "schema": { "type": "string", "title": "Code" } } ], "responses": { "200": { "description": "Successful Response", "content": { "application/json": { "schema": {} } } }, "422": { "description": "Validation Error", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/HTTPValidationError" } } } } } } }, "/api/auth/me": { "get": { "tags": [ "auth" ], "summary": "Me", "description": "現在ログイン中のユーザー情報を返す。", "operationId": "me_api_auth_me_get", "responses": { "200": { "description": "Successful Response", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/UserResponse" } } } } } } }, "/api/auth/logout": { "post": { "tags": [ "auth" ], "summary": "Logout", "description": "Cookie を削除してログアウトする。", "operationId": "logout_api_auth_logout_post", "responses": { "200": { "description": "Successful Response", "content": { "application/json": { "schema": {} } } } } } }, "/api/chat": { "post": { "tags": [ "chat" ], "summary": "Chat", "description": "Dify Chat API を呼び出してLLMの回答を返すエンドポイント。", "operationId": "chat_api_chat_post", "requestBody": { "content": { "application/json": { "schema": { "$ref": "#/components/schemas/ChatRequest" } } }, "required": true }, "responses": { "200": { "description": "Successful Response", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/ChatResponse" } } } }, "422": { "description": "Validation Error", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/HTTPValidationError" } } } } } } }, "/api/faq/search": { "get": { "tags": [ "faq" ], "summary": "Search Faq", "description": "FAQをキーワードで検索するエンドポイント(P0: LIKE検索)。", "operationId": "search_faq_api_faq_search_get", "parameters": [ { "name": "q", "in": "query", "required": true, "schema": { "type": "string", "minLength": 1, "maxLength": 200, "description": "検索キーワード", "title": "Q" }, "description": "検索キーワード" } ], "responses": { "200": { "description": "Successful Response", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/FaqSearchResponse" } } } }, "422": { "description": "Validation Error", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/HTTPValidationError" } } } } } } }, "/api/feedback": { "post": { "tags": [ "feedback" ], "summary": "Create Feedback", "description": "チャット回答への👍/👎フィードバックを保存するエンドポイント。", "operationId": "create_feedback_api_feedback_post", "requestBody": { "content": { "application/json": { "schema": { "$ref": "#/components/schemas/FeedbackCreate" } } }, "required": true }, "responses": { "201": { "description": "Successful Response", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/FeedbackResponse" } } } }, "422": { "description": "Validation Error", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/HTTPValidationError" } } } } } } }, "/api/usage-logs": { "post": { "tags": [ "usage-logs" ], "summary": "Create Usage Log", "description": "チャットAPIから呼ばれるトークン消費ログ保存エンドポイント。", "operationId": "create_usage_log_api_usage_logs_post", "requestBody": { "content": { "application/json": { "schema": { "$ref": "#/components/schemas/UsageLogCreate" } } }, "required": true }, "responses": { "201": { "description": "Successful Response", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/UsageLogResponse" } } } }, "422": { "description": "Validation Error", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/HTTPValidationError" } } } } } } }, "/api/admin/stats": { "get": { "tags": [ "admin" ], "summary": "Admin Stats", "description": "管理ダッシュボード用KPI集計エンドポイント。", "operationId": "admin_stats_api_admin_stats_get", "responses": { "200": { "description": "Successful Response", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/AdminStatsResponse" } } } } } } }, "/api/admin/feedbacks": { "get": { "tags": [ "admin" ], "summary": "Feedback List", "description": "フィードバック一覧を返す。", "operationId": "feedback_list_api_admin_feedbacks_get", "parameters": [ { "name": "limit", "in": "query", "required": false, "schema": { "type": "integer", "maximum": 200, "minimum": 1, "default": 50, "title": "Limit" } }, { "name": "offset", "in": "query", "required": false, "schema": { "type": "integer", "minimum": 0, "default": 0, "title": "Offset" } } ], "responses": { "200": { "description": "Successful Response", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/FeedbackListResponse" } } } }, "422": { "description": "Validation Error", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/HTTPValidationError" } } } } } } } }, "components": { "schemas": { "AdminStatsResponse": { "properties": { "daily_counts": { "items": { "$ref": "#/components/schemas/DailyCount" }, "type": "array", "title": "Daily Counts" }, "total_tokens": { "type": "integer", "title": "Total Tokens" }, "good_rate": { "type": "number", "title": "Good Rate" } }, "type": "object", "required": [ "daily_counts", "total_tokens", "good_rate" ], "title": "AdminStatsResponse" }, "ChatRequest": { "properties": { "session_id": { "type": "string", "maxLength": 128, "minLength": 1, "title": "Session Id" }, "message": { "type": "string", "maxLength": 5000, "minLength": 1, "title": "Message" } }, "type": "object", "required": [ "session_id", "message" ], "title": "ChatRequest", "description": "チャットリクエスト。" }, "ChatResponse": { "properties": { "answer": { "type": "string", "title": "Answer" }, "tokens_used": { "type": "integer", "title": "Tokens Used" } }, "type": "object", "required": [ "answer", "tokens_used" ], "title": "ChatResponse", "description": "チャットレスポンス。" }, "DailyCount": { "properties": { "date": { "type": "string", "format": "date", "title": "Date" }, "count": { "type": "integer", "title": "Count" } }, "type": "object", "required": [ "date", "count" ], "title": "DailyCount" }, "FaqSearchResponse": { "properties": { "results": { "items": { "$ref": "#/components/schemas/FaqSearchResult" }, "type": "array", "title": "Results" } }, "type": "object", "required": [ "results" ], "title": "FaqSearchResponse", "description": "FAQ検索レスポンス。" }, "FaqSearchResult": { "properties": { "content": { "type": "string", "title": "Content" } }, "type": "object", "required": [ "content" ], "title": "FaqSearchResult", "description": "FAQ検索結果の1件。" }, "FeedbackCreate": { "properties": { "session_id": { "type": "string", "maxLength": 128, "minLength": 1, "title": "Session Id" }, "rating": { "type": "string", "enum": [ "good", "bad" ], "title": "Rating" }, "comment": { "anyOf": [ { "type": "string", "maxLength": 500 }, { "type": "null" } ], "title": "Comment" } }, "type": "object", "required": [ "session_id", "rating" ], "title": "FeedbackCreate", "description": "フィードバック作成リクエスト。" }, "FeedbackItem": { "properties": { "id": { "type": "string", "title": "Id" }, "session_id": { "type": "string", "title": "Session Id" }, "rating": { "type": "string", "enum": [ "good", "bad" ], "title": "Rating" }, "comment": { "anyOf": [ { "type": "string" }, { "type": "null" } ], "title": "Comment" }, "created_at": { "type": "string", "format": "date-time", "title": "Created At" } }, "type": "object", "required": [ "id", "session_id", "rating", "comment", "created_at" ], "title": "FeedbackItem", "description": "フィードバック一覧の1件。" }, "FeedbackListResponse": { "properties": { "feedbacks": { "items": { "$ref": "#/components/schemas/FeedbackItem" }, "type": "array", "title": "Feedbacks" }, "total": { "type": "integer", "title": "Total" } }, "type": "object", "required": [ "feedbacks", "total" ], "title": "FeedbackListResponse", "description": "フィードバック一覧レスポンス。" }, "FeedbackResponse": { "properties": { "id": { "type": "string", "title": "Id" }, "session_id": { "type": "string", "title": "Session Id" }, "rating": { "type": "string", "enum": [ "good", "bad" ], "title": "Rating" }, "comment": { "anyOf": [ { "type": "string" }, { "type": "null" } ], "title": "Comment" }, "created_at": { "type": "string", "format": "date-time", "title": "Created At" } }, "type": "object", "required": [ "id", "session_id", "rating", "comment", "created_at" ], "title": "FeedbackResponse", "description": "フィードバックレスポンス。" }, "HTTPValidationError": { "properties": { "detail": { "items": { "$ref": "#/components/schemas/ValidationError" }, "type": "array", "title": "Detail" } }, "type": "object", "title": "HTTPValidationError" }, "HealthResponse": { "properties": { "status": { "type": "string", "title": "Status" }, "db": { "type": "string", "title": "Db" } }, "type": "object", "required": [ "status", "db" ], "title": "HealthResponse" }, "UsageLogCreate": { "properties": { "session_id": { "type": "string", "minLength": 1, "title": "Session Id" }, "tokens": { "type": "integer", "minimum": 1.0, "title": "Tokens" }, "category": { "anyOf": [ { "type": "string" }, { "type": "null" } ], "title": "Category" } }, "type": "object", "required": [ "session_id", "tokens" ], "title": "UsageLogCreate", "description": "トークン消費ログ作成リクエスト。" }, "UsageLogResponse": { "properties": { "id": { "type": "string", "title": "Id" }, "session_id": { "type": "string", "title": "Session Id" }, "tokens": { "type": "integer", "title": "Tokens" }, "category": { "anyOf": [ { "type": "string" }, { "type": "null" } ], "title": "Category" }, "created_at": { "type": "string", "format": "date-time", "title": "Created At" } }, "type": "object", "required": [ "id", "session_id", "tokens", "category", "created_at" ], "title": "UsageLogResponse", "description": "トークン消費ログレスポンス。" }, "UserResponse": { "properties": { "id": { "type": "string", "title": "Id" }, "discord_user_id": { "type": "string", "title": "Discord User Id" }, "user_name": { "type": "string", "title": "User Name" }, "role": { "$ref": "#/components/schemas/UserRole" } }, "type": "object", "required": [ "id", "discord_user_id", "user_name", "role" ], "title": "UserResponse", "description": "管理ユーザー情報レスポンス。" }, "UserRole": { "type": "string", "enum": [ "ADMIN", "MEMBER" ], "title": "UserRole", "description": "管理ユーザーのロール。" }, "ValidationError": { "properties": { "loc": { "items": { "anyOf": [ { "type": "string" }, { "type": "integer" } ] }, "type": "array", "title": "Location" }, "msg": { "type": "string", "title": "Message" }, "type": { "type": "string", "title": "Error Type" }, "input": { "title": "Input" }, "ctx": { "type": "object", "title": "Context" } }, "type": "object", "required": [ "loc", "msg", "type" ], "title": "ValidationError" } } } }