diff --git a/doc/openapi/openapi.json b/doc/openapi/openapi.json deleted file mode 100644 index 0d16773..0000000 --- a/doc/openapi/openapi.json +++ /dev/null @@ -1,339 +0,0 @@ -{ - "openapi": "3.0.3", - "info": { - "title": "MH-API", - "version": "1.0.0" - }, - "servers": [ - { - "url": "https://mh-api-xpzdc5i4rq-an.a.run.app", - "description": "PROD環境" - } - ], - "paths": { - "/v1/health": { - "get": { - "summary": "ヘルスチェックエンドポイント", - "responses": { - "200": { - "description": "OK" - } - } - } - }, - "/v1/monsters": { - "get": { - "summary": "全てのモンスター情報を取得する", - "requestBody": { - "$ref": "#/components/schemas/Monsters" - }, - "responses": { - "200": { - "description": "モンスター情報の取得に成功", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/Monsters" - } - } - } - }, - "404": { - "description": "モンスターが見つかりません", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/FailedResponse" - } - } - } - } - } - }, - "post": { - "summary": "モンスターの情報を追加する", - "responses": { - "200": { - "description": "モンスターの情報の登録に成功", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/SuccessResponse" - } - } - } - }, - "403": { - "description": "認証失敗", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/FailedResponse" - } - } - } - }, - "500": { - "description": "サーバエラーにより更新失敗", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/FailedResponse" - } - } - } - } - } - } - }, - "/v1/monsters/{id}": { - "get": { - "summary": "モンスター情報を取得する", - "parameters": [ - { - "$ref": "#/components/parameters/PathId" - } - ], - "responses": { - "200": { - "description": "モンスター情報の取得に成功", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/Monster" - } - } - } - }, - "404": { - "description": "モンスターの情報が見つかりません", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/FailedResponse" - } - } - } - } - } - } - }, - "/v1/monsters/json": { - "post": { - "summary": "jsonを使用してモンスターの情報一括追加する", - "responses": { - "200": { - "description": "モンスターの情報の登録に成功" - }, - "403": { - "description": "認証失敗", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/FailedResponse" - } - } - } - }, - "500": { - "description": "サーバエラーによ登録失敗", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/FailedResponse" - } - } - } - } - } - } - }, - "/v1/monsters/{updateid}": { - "patch": { - "summary": "モンスターの情報を更新する", - "parameters": [ - { - "$ref": "#/components/schemas/Monster" - } - ], - "responses": { - "200": { - "description": "モンスターの情報の更新に成功" - }, - "403": { - "description": "認証失敗", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/FailedResponse" - } - } - } - }, - "500": { - "description": "サーバエラーにより更新失敗", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/FailedResponse" - } - } - } - } - } - } - }, - "/v1/monsters/{deleteid}": { - "get": { - "summary": "モンスターの情報を削除する", - "parameters": [ - { - "$ref": "#/components/parameters/PathId" - } - ], - "responses": { - "200": { - "description": "モンスターの情報の削除に成功" - }, - "403": { - "description": "認証失敗", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/FailedResponse" - } - } - } - }, - "500": { - "description": "サーバエラーにより削除失敗", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/FailedResponse" - } - } - } - } - } - } - } - }, - "components": { - "parameters": { - "PathId": { - "name": "id", - "in": "path", - "description": "モンスターのID", - "required": true, - "schema": { - "type": "integer" - } - } - }, - "requestBodies": { - "Monster": { - "content": { - "application/json": { - "schema": { - "type": "object", - "required": [ - "name" - ], - "properties": { - "name": { - "type": "string" - }, - "desc": { - "type": "string" - }, - "location": { - "type": "string" - }, - "specify": { - "type": "string" - }, - "weakness_attack": { - "type": "string" - }, - "weakness_element": { - "type": "string" - } - } - } - } - } - } - }, - "schemas": { - "Monster": { - "type": "object", - "properties": { - "id": { - "type": "integer" - }, - "name": { - "type": "string" - }, - "desc": { - "type": "string" - }, - "location": { - "type": "string" - }, - "specify": { - "type": "string" - }, - "weakness_attack": { - "type": "string" - }, - "weakness_element": { - "type": "string" - } - } - }, - "Monsters": { - "type": "array", - "properties": { - "id": { - "type": "integer" - }, - "name": { - "type": "string" - }, - "desc": { - "type": "string" - }, - "location": { - "type": "string" - }, - "specify": { - "type": "string" - }, - "weakness_attack": { - "type": "string" - }, - "weakness_element": { - "type": "string" - } - } - }, - "SuccessResponse": { - "type": "string", - "properties": { - "message": { - "type": "string" - } - } - }, - "FailedResponse": { - "type": "string", - "properties": { - "error": { - "type": "string" - } - } - } - } - } -} \ No newline at end of file diff --git a/doc/openapi/schema.yml b/doc/openapi/schema.yml deleted file mode 100644 index f7e5283..0000000 --- a/doc/openapi/schema.yml +++ /dev/null @@ -1,418 +0,0 @@ -openapi: 3.0.0 -info: - title: MH-API - description: Monster Hunter API Documentation - version: 1.0.0 -servers: - - url: https://mh-api-v2-8aznfogc.an.gateway.dev/ - description: PROD環境 - - url: http://localhost:8080 - description: ローカル環境 -paths: - /v1/health: - get: - summary: ヘルスチェックエンドポイント - responses: - "200": - description: OK - content: - application/json: - example: - Message: OK - /v1/monsters: - get: - summary: 全てのモンスター情報を取得する - responses: - "200": - description: モンスター情報の取得に成功 - content: - application/json: - example: - total: 2 - monsters: - - monster_id: "1" - name: "Rathalos" - desc: "King of the Skies" - location: "Ancient Forest" - category: "Flying Wyvern" - title: "King of the Skies" - weakness_attack: - front_legs: - slashing: "10" - blow: "10" - bullet: "10" - tail: - slashing: "10" - blow: "10" - bullet: "10" - hind_legs: - slashing: "10" - blow: "10" - bullet: "10" - body: - slashing: "10" - blow: "10" - bullet: "10" - head: - slashing: "10" - blow: "10" - bullet: "10" - weakness_element: - front_legs: - fire: "10" - water: "10" - lightning: "10" - ice: "10" - dragon: "10" - tail: - fire: "10" - water: "10" - lightning: "10" - ice: "10" - dragon: "10" - hind_legs: - fire: "10" - water: "10" - lightning: "10" - ice: "10" - dragon: "10" - body: - fire: "10" - water: "10" - lightning: "10" - ice: "10" - dragon: "10" - head: - fire: "10" - water: "10" - lightning: "10" - ice: "10" - dragon: "10" - - monster_id: "2" - name: "Diablos" - desc: "Horned Wyvern" - location: "Wildspire Waste" - category: "Brute Wyvern" - title: "Horned Tyrant" - weakness_attack: - front_legs: - slashing: "15" - blow: "12" - bullet: "8" - tail: - slashing: "18" - blow: "15" - bullet: "10" - hind_legs: - slashing: "12" - blow: "10" - bullet: "8" - body: - slashing: "20" - blow: "18" - bullet: "15" - head: - slashing: "25" - blow: "20" - bullet: "18" - weakness_element: - front_legs: - fire: "20" - water: "15" - lightning: "10" - ice: "5" - dragon: "15" - tail: - fire: "15" - water: "10" - lightning: "5" - ice: "20" - dragon: "18" - hind_legs: - fire: "10" - water: "5" - lightning: "20" - ice: "15" - dragon: "10" - body: - fire: "5" - water: "18" - lightning: "15" - ice: "10" - dragon: "20" - head: - fire: "18" - water: "20" - lightning: "12" - ice: "15" - dragon: "25" - "404": - description: モンスターが見つかりません - content: - application/json: - example: - message: Not Found - post: - summary: モンスターの情報を追加する - requestBody: - required: true - content: - application/json: - schema: - $ref: "#/components/schemas/Json" - responses: - "200": - description: モンスターの情報の登録に成功 - content: - application/json: - example: - message: "success!" - "403": - description: 認証失敗 - content: - application/json: - example: - message: Authentication error - - "500": - description: サーバエラーにより更新失敗 - content: - application/json: - example: - message: Internal Server Error - - /v1/monsters/{id}: - get: - summary: モンスター情報を取得する - parameters: - - in: path - name: id - required: true - schema: - type: string - responses: - "200": - description: モンスターの情報の登録に成功 - content: - application/json: - example: - monster: - monster_id: "1" - name: "Rathalos" - desc: "King of the Skies" - location: "Ancient Forest" - category: "Flying Wyvern" - title: "King of the Skies" - weakness_attack: - front_legs: - slashing: "10" - blow: "10" - bullet: "10" - tail: - slashing: "10" - blow: "10" - bullet: "10" - hind_legs: - slashing: "10" - blow: "10" - bullet: "10" - body: - slashing: "10" - blow: "10" - bullet: "10" - head: - slashing: "10" - blow: "10" - bullet: "10" - weakness_element: - front_legs: - fire: "10" - water: "10" - lightning: "10" - ice: "10" - dragon: "10" - tail: - fire: "10" - water: "10" - lightning: "10" - ice: "10" - dragon: "10" - hind_legs: - fire: "10" - water: "10" - lightning: "10" - ice: "10" - dragon: "10" - body: - fire: "10" - water: "10" - lightning: "10" - ice: "10" - dragon: "10" - head: - fire: "10" - water: "10" - lightning: "10" - ice: "10" - dragon: "10" - "403": - description: 認証失敗 - content: - application/json: - example: - message: Authentication error - "500": - description: サーバエラーによ登録失敗 - content: - application/json: - example: - message: Internal Server Error - put: - summary: モンスターの情報の更新に成功 - parameters: - - in: path - name: id - required: true - schema: - type: string - requestBody: - required: true - content: - application/json: - schema: - $ref: "#/components/schemas/Json" - responses: - "200": - description: モンスターの情報の更新に成功 - content: - application/json: - example: - message: "success!" - "403": - description: 認証失敗 - content: - application/json: - example: - meesage: Authentication error - "500": - description: サーバエラーにより更新失敗 - content: - application/json: - example: - message: Internal Server Errorr - /v1/monsters/{deleteid}: - delete: - summary: モンスターの情報を削除する - parameters: - - in: path - name: id - required: true - schema: - type: string - responses: - "200": - description: モンスターの情報の削除に成功 - content: - application/json: - example: - message: "success!" - "403": - description: 認証失敗 - content: - application/json: - example: - message: Authentication error - "500": - description: サーバエラーにより削除失敗 - content: - application/json: - example: - message: Internal Server Error - -components: - schemas: - Json: - type: object - properties: - monster_id: - type: string - example: "1" - name: - type: string - example: "Rathalos" - desc: - type: string - example: "King of the Skies" - location: - type: string - example: "Ancient Forest" - category: - type: string - example: "Flying Wyvern" - title: - type: string - example: "King of the Skies" - weakness_attack: - $ref: "#/components/schemas/Weakness_attack" - weakness_element: - $ref: "#/components/schemas/Weakness_element" - - Weakness_attack: - type: object - properties: - front_legs: - $ref: "#/components/schemas/AttackCatetgory" - tail: - $ref: "#/components/schemas/AttackCatetgory" - hind_legs: - $ref: "#/components/schemas/AttackCatetgory" - body: - $ref: "#/components/schemas/AttackCatetgory" - head: - $ref: "#/components/schemas/AttackCatetgory" - - Weakness_element: - type: object - properties: - front_legs: - $ref: "#/components/schemas/Elements" - tail: - $ref: "#/components/schemas/Elements" - hind_legs: - $ref: "#/components/schemas/Elements" - body: - $ref: "#/components/schemas/Elements" - head: - $ref: "#/components/schemas/Elements" - - AttackCatetgory: - type: object - properties: - slashing: - type: string - example: "10" - blow: - type: string - example: "10" - bullet: - type: string - example: "10" - - Elements: - type: object - properties: - fire: - type: string - example: "10" - water: - type: string - example: "10" - lightning: - type: string - example: "10" - ice: - type: string - example: "10" - dragon: - type: string - example: "10" diff --git a/doc/openapi/swagger.json b/doc/openapi/swagger.json index 718200b..572a092 100644 --- a/doc/openapi/swagger.json +++ b/doc/openapi/swagger.json @@ -13,9 +13,9 @@ "host": "https://mh-api-v2-8aznfogc.an.gateway.dev/", "basePath": "/v1", "paths": { - "/items/:itemId": { + "/armors": { "get": { - "description": "アイテムを検索して、条件に合致するアイテムを1件取得する", + "description": "防具を検索して一覧を返します(名前・スキル名・スロットによる絞り込み・ページネーション対応)", "consumes": [ "application/json" ], @@ -23,44 +23,306 @@ "application/json" ], "tags": [ - "アイテム検索" + "Armors" ], - "summary": "アイテム検索(1件)", + "summary": "防具一覧を取得します", "parameters": [ { "type": "string", - "name": "item_name", + "description": "防具名(部分一致)", + "name": "name", + "in": "query" + }, + { + "type": "string", + "description": "スキル名(部分一致)", + "name": "skill_name", "in": "query" }, { "type": "string", - "name": "item_name_kana", + "description": "スロット(完全一致)", + "name": "slot", "in": "query" }, { "type": "integer", + "default": 100, + "description": "取得件数", "name": "limit", "in": "query" }, + { + "type": "integer", + "default": 0, + "description": "取得開始位置", + "name": "offset", + "in": "query" + }, + { + "type": "string", + "description": "ソート順 (asc/desc)", + "name": "sort", + "in": "query" + } + ], + "responses": { + "200": { + "description": "防具のリスト", + "schema": { + "$ref": "#/definitions/armor.ListArmorsResponse" + } + }, + "400": { + "description": "リクエストパラメータが不正な場合", + "schema": { + "$ref": "#/definitions/armor.ErrorResponse" + } + }, + "500": { + "description": "サーバ内部エラー", + "schema": { + "$ref": "#/definitions/armor.ErrorResponse" + } + } + } + } + }, + "/armors/{id}": { + "get": { + "description": "指定されたIDの防具の詳細を返します。", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "Armors" + ], + "summary": "防具詳細を取得します", + "parameters": [ { "type": "string", + "description": "防具ID", + "name": "id", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "防具の詳細", + "schema": { + "$ref": "#/definitions/armor.ArmorDetailResponse" + } + }, + "400": { + "description": "リクエストパラメータが不正な場合", + "schema": { + "$ref": "#/definitions/armor.ErrorResponse" + } + }, + "404": { + "description": "防具が見つからない場合", + "schema": { + "$ref": "#/definitions/armor.ErrorResponse" + } + }, + "500": { + "description": "サーバ内部エラー", + "schema": { + "$ref": "#/definitions/armor.ErrorResponse" + } + } + } + } + }, + "/health": { + "get": { + "description": "システムが稼働しているか確認する", + "produces": [ + "application/json" + ], + "tags": [ + "System" + ], + "summary": "ヘルスチェック", + "responses": { + "200": { + "description": "OK", + "schema": { + "type": "object", + "additionalProperties": { + "type": "string" + } + } + } + } + } + }, + "/health/db": { + "get": { + "description": "データベースへの接続を確認する", + "produces": [ + "application/json" + ], + "tags": [ + "System" + ], + "summary": "DBヘルスチェック", + "responses": { + "200": { + "description": "OK", + "schema": { + "type": "object", + "additionalProperties": { + "type": "string" + } + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "type": "object", + "additionalProperties": { + "type": "string" + } + } + } + } + } + }, + "/items": { + "get": { + "description": "アイテムを検索して一覧を取得する(名前・モンスターIDによる絞り込み・ページネーション対応)", + "produces": [ + "application/json" + ], + "tags": [ + "アイテム検索" + ], + "summary": "アイテム名の一覧を取得する", + "parameters": [ + { + "type": "string", + "description": "アイテム名(部分一致)", + "name": "name", + "in": "query" + }, + { + "type": "string", + "description": "モンスターID(完全一致)", "name": "monster_id", "in": "query" }, { "type": "integer", - "name": "offset", + "default": 100, + "description": "取得件数", + "name": "limit", "in": "query" }, { "type": "integer", - "name": "order", + "default": 0, + "description": "取得開始位置", + "name": "offset", "in": "query" + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/item.Items" + } + }, + "400": { + "description": "Bad Request", + "schema": { + "$ref": "#/definitions/item.MessageResponse" + } }, + "500": { + "description": "Internal Server Error", + "schema": { + "$ref": "#/definitions/item.MessageResponse" + } + } + } + } + }, + "/items/monster/{monsterId}": { + "get": { + "description": "指定のアイテムが取得可能なモンスターの一覧", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "アイテム検索" + ], + "summary": "アイテム検索(モンスター別)", + "parameters": [ { "type": "string", - "name": "sort", - "in": "query" + "description": "モンスターID", + "name": "monsterId", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/item.ItemsByMonster" + } + }, + "400": { + "description": "Bad Request", + "schema": { + "$ref": "#/definitions/item.MessageResponse" + } + }, + "404": { + "description": "Not Found", + "schema": { + "$ref": "#/definitions/item.MessageResponse" + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "$ref": "#/definitions/item.MessageResponse" + } + } + } + } + }, + "/items/{itemId}": { + "get": { + "description": "アイテムを検索して、条件に合致するアイテムを1件取得する", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "アイテム検索" + ], + "summary": "アイテム検索(1件)", + "parameters": [ + { + "type": "string", + "description": "アイテムID", + "name": "itemId", + "in": "path", + "required": true } ], "responses": { @@ -107,26 +369,63 @@ "parameters": [ { "type": "string", + "description": "モンスターIDs (カンマ区切り)", "name": "MonsterIds", "in": "query" }, { "type": "string", + "description": "モンスター名", "name": "MonsterName", "in": "query" }, + { + "type": "string", + "description": "使用属性", + "name": "UsageElement", + "in": "query" + }, + { + "type": "string", + "description": "弱点属性", + "name": "WeaknessElement", + "in": "query" + }, + { + "type": "string", + "description": "種族名", + "name": "TribeName", + "in": "query" + }, + { + "type": "string", + "description": "フィールド名", + "name": "FieldName", + "in": "query" + }, + { + "type": "string", + "description": "作品名", + "name": "ProductName", + "in": "query" + }, { "type": "integer", + "default": 100, + "description": "取得件数", "name": "limit", "in": "query" }, { "type": "integer", + "default": 0, + "description": "取得開始位置", "name": "offset", "in": "query" }, { "type": "string", + "description": "ソート順 (asc/desc)", "name": "sort", "in": "query" } @@ -159,7 +458,7 @@ } } }, - "/monsters/:monsterid": { + "/monsters/{id}": { "get": { "description": "モンスターを検索して、条件に合致するモンスターを1件取得する", "consumes": [ @@ -176,8 +475,9 @@ { "type": "string", "description": "モンスターID", - "name": "request", - "in": "path" + "name": "id", + "in": "path", + "required": true } ], "responses": { @@ -208,87 +508,119 @@ } } }, - "/weapons": { + "/skills": { "get": { - "description": "武器を検索して、条件に合致する武器を複数件取得する", - "consumes": [ - "application/json" - ], + "description": "スキルを検索して一覧を取得する(名前・説明文による絞り込み・ページネーション対応)", "produces": [ "application/json" ], "tags": [ - "武器検索" + "スキル検索" ], - "summary": "武器検索(複数件)", + "summary": "スキル一覧を取得する", "parameters": [ - { - "type": "integer", - "name": "limit", - "in": "query" - }, - { - "type": "string", - "name": "monster_id", - "in": "query" - }, { "type": "string", + "description": "スキル名(部分一致)", "name": "name", "in": "query" }, { "type": "string", - "name": "name_kana", + "description": "説明文(部分一致)", + "name": "description", "in": "query" }, { "type": "integer", - "name": "offset", + "default": 100, + "description": "取得件数", + "name": "limit", "in": "query" }, { "type": "integer", - "name": "order", + "default": 0, + "description": "取得開始位置", + "name": "offset", "in": "query" + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/skill.Skills" + } + }, + "400": { + "description": "Bad Request", + "schema": { + "$ref": "#/definitions/skill.MessageResponse" + } }, + "500": { + "description": "Internal Server Error", + "schema": { + "$ref": "#/definitions/skill.MessageResponse" + } + } + } + } + }, + "/skills/{skillId}": { + "get": { + "description": "スキルを検索して、条件に合致するスキルを1件取得する", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "スキル検索" + ], + "summary": "スキル検索(1件)", + "parameters": [ { "type": "string", - "name": "sort", - "in": "query" + "description": "スキルID", + "name": "skillId", + "in": "path", + "required": true } ], "responses": { "200": { "description": "OK", "schema": { - "$ref": "#/definitions/weapon.Weapon" + "$ref": "#/definitions/skill.Skill" } }, "400": { "description": "Bad Request", "schema": { - "$ref": "#/definitions/weapon.MessageResponse" + "$ref": "#/definitions/skill.MessageResponse" } }, "404": { "description": "Not Found", "schema": { - "$ref": "#/definitions/weapon.MessageResponse" + "$ref": "#/definitions/skill.MessageResponse" } }, "500": { "description": "Internal Server Error", "schema": { - "$ref": "#/definitions/weapon.MessageResponse" + "$ref": "#/definitions/skill.MessageResponse" } } } } }, - "/weapons/:bgmid": { + "/weapons": { "get": { - "description": "武器を検索して、条件に合致する武器を1件取得する", + "description": "指定されたクエリパラメータに基づいて武器のリストを返します。", "consumes": [ "application/json" ], @@ -296,69 +628,66 @@ "application/json" ], "tags": [ - "武器検索" + "Weapons" ], - "summary": "武器検索(1件)", + "summary": "武器リストを検索します", "parameters": [ - { - "type": "integer", - "name": "limit", - "in": "query" - }, { "type": "string", - "name": "monster_id", + "description": "武器ID (完全一致)", + "name": "weapon_id", "in": "query" }, { "type": "string", + "description": "武器名 (部分一致を想定)", "name": "name", "in": "query" }, { - "type": "string", - "name": "name_kana", + "type": "integer", + "default": 20, + "description": "取得件数", + "name": "limit", "in": "query" }, { "type": "integer", + "default": 0, + "description": "取得開始位置", "name": "offset", "in": "query" }, { - "type": "integer", - "name": "order", + "type": "string", + "description": "ソートフィールド (asc/desc)", + "name": "sort", "in": "query" }, { - "type": "string", - "name": "sort", + "type": "integer", + "description": "ソート順 (0:昇順, 1:降順)", + "name": "order", "in": "query" } ], "responses": { "200": { - "description": "OK", + "description": "武器のリストとページネーション情報", "schema": { - "$ref": "#/definitions/weapon.Weapon" + "$ref": "#/definitions/weapon.ListWeaponsResponse" } }, "400": { - "description": "Bad Request", + "description": "リクエストパラメータが不正な場合", "schema": { - "$ref": "#/definitions/weapon.MessageResponse" - } - }, - "404": { - "description": "Not Found", - "schema": { - "$ref": "#/definitions/weapon.MessageResponse" + "$ref": "#/definitions/weapon.ErrorResponse" } }, "500": { - "description": "Internal Server Error", + "description": "サーバ内部エラー", "schema": { - "$ref": "#/definitions/weapon.MessageResponse" + "$ref": "#/definitions/weapon.ErrorResponse" } } } @@ -366,6 +695,102 @@ } }, "definitions": { + "armor.ArmorDetailResponse": { + "type": "object", + "properties": { + "defense": { + "type": "integer" + }, + "id": { + "type": "string" + }, + "name": { + "type": "string" + }, + "required": { + "type": "array", + "items": { + "$ref": "#/definitions/armor.RequiredItemResponse" + } + }, + "resistance": { + "$ref": "#/definitions/armor.ResistanceResponse" + }, + "skills": { + "type": "array", + "items": { + "$ref": "#/definitions/armor.SkillResponse" + } + }, + "slot": { + "type": "string" + } + } + }, + "armor.ErrorResponse": { + "type": "object", + "properties": { + "message": { + "type": "string" + } + } + }, + "armor.ListArmorsResponse": { + "type": "object", + "properties": { + "armors": { + "type": "array", + "items": { + "$ref": "#/definitions/armor.ArmorDetailResponse" + } + }, + "total": { + "type": "integer" + } + } + }, + "armor.RequiredItemResponse": { + "type": "object", + "properties": { + "id": { + "type": "string" + }, + "name": { + "type": "string" + } + } + }, + "armor.ResistanceResponse": { + "type": "object", + "properties": { + "dragon": { + "type": "integer" + }, + "fire": { + "type": "integer" + }, + "ice": { + "type": "integer" + }, + "lightning": { + "type": "integer" + }, + "water": { + "type": "integer" + } + } + }, + "armor.SkillResponse": { + "type": "object", + "properties": { + "id": { + "type": "string" + }, + "name": { + "type": "string" + } + } + }, "item.Item": { "type": "object", "properties": { @@ -374,6 +799,43 @@ } } }, + "item.Items": { + "type": "object", + "properties": { + "items": { + "type": "array", + "items": { + "$ref": "#/definitions/item.ResponseJson" + } + }, + "limit": { + "type": "integer" + }, + "offset": { + "type": "integer" + }, + "total": { + "type": "integer" + } + } + }, + "item.ItemsByMonster": { + "type": "object", + "properties": { + "items": { + "type": "array", + "items": { + "$ref": "#/definitions/item.Item" + } + }, + "monster_id": { + "type": "string" + }, + "monster_name": { + "type": "string" + } + } + }, "item.MessageResponse": { "type": "object", "properties": { @@ -469,6 +931,14 @@ "description": "モンスターのカテゴリ", "type": "string" }, + "description": { + "description": "モンスターの説明", + "type": "string" + }, + "element": { + "description": "モンスターの属性", + "type": "string" + }, "first_weak_attack": { "description": "最有効弱点", "type": "string" @@ -496,6 +966,10 @@ "description": "モンスター名", "type": "string" }, + "name_en": { + "description": "モンスター名(英語)", + "type": "string" + }, "ranking": { "description": "人気投票ランキング", "type": "array", @@ -568,7 +1042,75 @@ } } }, - "weapon.MessageResponse": { + "skill.MessageResponse": { + "type": "object", + "properties": { + "message": { + "type": "string" + } + } + }, + "skill.ResponseSkill": { + "type": "object", + "properties": { + "description": { + "type": "string" + }, + "id": { + "type": "string" + }, + "level": { + "type": "array", + "items": { + "$ref": "#/definitions/skill.ResponseSkillLevel" + } + }, + "name": { + "type": "string" + } + } + }, + "skill.ResponseSkillLevel": { + "type": "object", + "additionalProperties": { + "type": "string" + } + }, + "skill.Skill": { + "type": "object", + "properties": { + "description": { + "type": "string" + }, + "id": { + "type": "string" + }, + "level": { + "type": "array", + "items": { + "$ref": "#/definitions/skill.ResponseSkillLevel" + } + }, + "name": { + "type": "string" + } + } + }, + "skill.Skills": { + "type": "object", + "properties": { + "skills": { + "type": "array", + "items": { + "$ref": "#/definitions/skill.ResponseSkill" + } + }, + "total": { + "type": "integer" + } + } + }, + "weapon.ErrorResponse": { "type": "object", "properties": { "message": { @@ -576,7 +1118,27 @@ } } }, - "weapon.ResponseJson": { + "weapon.ListWeaponsResponse": { + "type": "object", + "properties": { + "limit": { + "type": "integer" + }, + "offset": { + "type": "integer" + }, + "total_count": { + "type": "integer" + }, + "weapons": { + "type": "array", + "items": { + "$ref": "#/definitions/weapon.WeaponDetailResponse" + } + } + } + }, + "weapon.WeaponDetailResponse": { "type": "object", "properties": { "attack": { @@ -588,31 +1150,23 @@ "description": { "type": "string" }, - "elemant_attaxk": { + "element_attack": { "type": "string" }, "image_url": { "type": "string" }, - "monster_id": { - "type": "string" - }, "name": { "type": "string" }, "rare": { "type": "string" }, - "shapness": { + "sharpness": { + "type": "string" + }, + "weapon_id": { "type": "string" - } - } - }, - "weapon.Weapon": { - "type": "object", - "properties": { - "monster": { - "$ref": "#/definitions/weapon.ResponseJson" } } } diff --git a/doc/openapi/swagger.yaml b/doc/openapi/swagger.yaml index 52b3d86..9ef4d6f 100644 --- a/doc/openapi/swagger.yaml +++ b/doc/openapi/swagger.yaml @@ -32,6 +32,8 @@ definitions: items: $ref: '#/definitions/armor.ArmorDetailResponse' type: array + total: + type: integer type: object armor.RequiredItemResponse: properties: @@ -270,6 +272,8 @@ definitions: items: $ref: '#/definitions/skill.ResponseSkill' type: array + total: + type: integer type: object weapon.ErrorResponse: properties: @@ -327,7 +331,34 @@ paths: get: consumes: - application/json - description: 全ての防具のリストを返します。 + description: 防具を検索して一覧を返します(名前・スキル名・スロットによる絞り込み・ページネーション対応) + parameters: + - description: 防具名(部分一致) + in: query + name: name + type: string + - description: スキル名(部分一致) + in: query + name: skill_name + type: string + - description: スロット(完全一致) + in: query + name: slot + type: string + - default: 100 + description: 取得件数 + in: query + name: limit + type: integer + - default: 0 + description: 取得開始位置 + in: query + name: offset + type: integer + - description: ソート順 (asc/desc) + in: query + name: sort + type: string produces: - application/json responses: @@ -335,6 +366,10 @@ paths: description: 防具のリスト schema: $ref: '#/definitions/armor.ListArmorsResponse' + "400": + description: リクエストパラメータが不正な場合 + schema: + $ref: '#/definitions/armor.ErrorResponse' "500": description: サーバ内部エラー schema: @@ -375,9 +410,64 @@ paths: summary: 防具詳細を取得します tags: - Armors + /health: + get: + description: システムが稼働しているか確認する + produces: + - application/json + responses: + "200": + description: OK + schema: + additionalProperties: + type: string + type: object + summary: ヘルスチェック + tags: + - System + /health/db: + get: + description: データベースへの接続を確認する + produces: + - application/json + responses: + "200": + description: OK + schema: + additionalProperties: + type: string + type: object + "500": + description: Internal Server Error + schema: + additionalProperties: + type: string + type: object + summary: DBヘルスチェック + tags: + - System /items: get: - description: 全てのアイテム名とIDの一覧を取得する + description: アイテムを検索して一覧を取得する(名前・モンスターIDによる絞り込み・ページネーション対応) + parameters: + - description: アイテム名(部分一致) + in: query + name: name + type: string + - description: モンスターID(完全一致) + in: query + name: monster_id + type: string + - default: 100 + description: 取得件数 + in: query + name: limit + type: integer + - default: 0 + description: 取得開始位置 + in: query + name: offset + type: integer produces: - application/json responses: @@ -429,7 +519,7 @@ paths: summary: アイテム検索(1件) tags: - アイテム検索 - /items/monsters/{monsterId}: + /items/monster/{monsterId}: get: consumes: - application/json @@ -468,29 +558,45 @@ paths: - application/json description: モンスターを検索して、条件に合致するモンスターを複数件取得する parameters: - - in: query + - description: モンスターIDs (カンマ区切り) + in: query name: MonsterIds type: string - - in: query + - description: モンスター名 + in: query name: MonsterName type: string - - in: query + - description: 使用属性 + in: query name: UsageElement type: string - - in: query + - description: 弱点属性 + in: query name: WeaknessElement type: string - - in: query - minimum: 0 + - description: 種族名 + in: query + name: TribeName + type: string + - description: フィールド名 + in: query + name: FieldName + type: string + - description: 作品名 + in: query + name: ProductName + type: string + - default: 100 + description: 取得件数 + in: query name: limit type: integer - - in: query - minimum: 0 + - default: 0 + description: 取得開始位置 + in: query name: offset type: integer - - enum: - - asc - - desc + - description: ソート順 (asc/desc) in: query name: sort type: string @@ -524,7 +630,7 @@ paths: parameters: - description: モンスターID in: path - name: request + name: id required: true type: string produces: @@ -551,7 +657,26 @@ paths: - モンスター検索 /skills: get: - description: 全てのスキルとその情報の一覧を取得する + description: スキルを検索して一覧を取得する(名前・説明文による絞り込み・ページネーション対応) + parameters: + - description: スキル名(部分一致) + in: query + name: name + type: string + - description: 説明文(部分一致) + in: query + name: description + type: string + - default: 100 + description: 取得件数 + in: query + name: limit + type: integer + - default: 0 + description: 取得開始位置 + in: query + name: offset + type: integer produces: - application/json responses: @@ -650,7 +775,7 @@ paths: description: サーバ内部エラー schema: $ref: '#/definitions/weapon.ErrorResponse' - summary: 武器リストを検索します (Gin版) + summary: 武器リストを検索します tags: - Weapons swagger: "2.0" diff --git a/internal/controller/item/handler.go b/internal/controller/item/handler.go index 245d5fc..ee613ad 100644 --- a/internal/controller/item/handler.go +++ b/internal/controller/item/handler.go @@ -106,7 +106,7 @@ func (h *ItemHandler) GetItem(c *gin.Context) { // @Failure 400 {object} MessageResponse // @Failure 404 {object} MessageResponse // @Failure 500 {object} MessageResponse -// @Router /items/monsters/{monsterId} [get] +// @Router /items/monster/{monsterId} [get] func (h *ItemHandler) GetItemByMonster(c *gin.Context) { var req RequestItemByMonster if err := c.ShouldBindUri(&req); err != nil { diff --git a/internal/controller/item/handler_test.go b/internal/controller/item/handler_test.go index 87481e8..736cc92 100644 --- a/internal/controller/item/handler_test.go +++ b/internal/controller/item/handler_test.go @@ -26,7 +26,7 @@ func MockNewServer(t *testing.T, handler *ItemHandler) *gin.Engine { func (h *ItemHandler) SetupRouter(r *gin.Engine) { r.GET("/v1/items", h.GetItems) r.GET("/v1/items/:itemId", h.GetItem) - r.GET("/v1/items/monsters/:monsterId", h.GetItemByMonster) + r.GET("/v1/items/monster/:monsterId", h.GetItemByMonster) } func TestItemHandler_GetItems(t *testing.T) { @@ -341,7 +341,7 @@ func TestItemHandler_GetItemByMonster(t *testing.T) { handler.SetupRouter(r) w := httptest.NewRecorder() - req, _ := http.NewRequest(http.MethodGet, fmt.Sprintf("/v1/items/monsters/%s", tt.pathParam), nil) + req, _ := http.NewRequest(http.MethodGet, fmt.Sprintf("/v1/items/monster/%s", tt.pathParam), nil) r.ServeHTTP(w, req) assert.Equal(t, tt.wantStatus, w.Code) diff --git a/internal/controller/monster/handler.go b/internal/controller/monster/handler.go index b80dd0b..34dbe78 100644 --- a/internal/controller/monster/handler.go +++ b/internal/controller/monster/handler.go @@ -24,6 +24,27 @@ func NewMonsterHandler(repo monsters.Repository) *MonsterHandler { return &MonsterHandler{repo: repo} } +// GetAll godoc +// @Summary モンスター検索(複数件) +// @Description モンスターを検索して、条件に合致するモンスターを複数件取得する +// @Tags モンスター検索 +// @Accept json +// @Produce json +// @Param MonsterIds query string false "モンスターIDs (カンマ区切り)" +// @Param MonsterName query string false "モンスター名" +// @Param UsageElement query string false "使用属性" +// @Param WeaknessElement query string false "弱点属性" +// @Param TribeName query string false "種族名" +// @Param FieldName query string false "フィールド名" +// @Param ProductName query string false "作品名" +// @Param limit query int false "取得件数" default(100) +// @Param offset query int false "取得開始位置" default(0) +// @Param sort query string false "ソート順 (asc/desc)" +// @Success 200 {object} Monsters +// @Failure 400 {object} MessageResponse +// @Failure 404 {object} MessageResponse +// @Failure 500 {object} MessageResponse +// @Router /monsters [get] func (m *MonsterHandler) GetAll(c *gin.Context) { ctx := c.Request.Context() @@ -86,7 +107,7 @@ func (m *MonsterHandler) GetAll(c *gin.Context) { // @Tags モンスター検索 // @Accept json // @Produce json -// @Param request path string true "モンスターID" +// @Param id path string true "モンスターID" // @Success 200 {object} Monster // @Failure 400 {object} MessageResponse // @Failure 404 {object} MessageResponse diff --git a/internal/controller/system.go b/internal/controller/system.go index c50b608..bdc5a0a 100644 --- a/internal/controller/system.go +++ b/internal/controller/system.go @@ -19,10 +19,25 @@ func NewHealthService(repo HealthRepository) SystemHandler { return SystemHandler{healthRepo: repo} } +// Health godoc +// @Summary ヘルスチェック +// @Description システムが稼働しているか確認する +// @Tags System +// @Produce json +// @Success 200 {object} map[string]string +// @Router /health [get] func (s *SystemHandler) Health(c *gin.Context) { c.JSON(200, gin.H{"Message": "ok"}) } +// DBHealth godoc +// @Summary DBヘルスチェック +// @Description データベースへの接続を確認する +// @Tags System +// @Produce json +// @Success 200 {object} map[string]string +// @Failure 500 {object} map[string]string +// @Router /health/db [get] func (s *SystemHandler) DBHealth(c *gin.Context) { ctx := c.Request.Context() err := s.healthRepo.GetStatus(ctx) diff --git a/internal/presenter/server.go b/internal/presenter/server.go index 0a7f513..beb5985 100644 --- a/internal/presenter/server.go +++ b/internal/presenter/server.go @@ -56,8 +56,8 @@ func NewServer() (*gin.Engine, error) { items := v1.Group("/items") { items.GET("", itemHandler.GetItems) - items.GET("/:id", itemHandler.GetItem) - items.GET("/monster/:monster_id", itemHandler.GetItemByMonster) + items.GET("/:itemId", itemHandler.GetItem) + items.GET("/monster/:monsterId", itemHandler.GetItemByMonster) } // 武器検索 diff --git a/makefile b/makefile index 4f1e788..de7c862 100644 --- a/makefile +++ b/makefile @@ -1,6 +1,6 @@ .PHONY: swagger swagger: - swag init --dir cmd/api,internal/controller/monster,internal/controller/weapon,internal/controller/skill,internal/controller/item,internal/controller/armor --output doc/openapi --outputTypes yaml + swag init --dir cmd/api,internal/controller --output doc/openapi --outputTypes yaml,json .PHONY: lint lint: