From da85d3d75a04650b549ed1b7473e8056700b0d3f Mon Sep 17 00:00:00 2001 From: shin0729 Date: Fri, 5 Apr 2024 15:06:55 +0900 Subject: [PATCH 1/6] =?UTF-8?q?add:=20=E3=83=A6=E3=83=BC=E3=82=B6=E3=83=BC?= =?UTF-8?q?=E3=81=AE=E7=8F=BE=E5=9C=A8=E3=81=AE=E9=A0=86=E4=BD=8D=E3=82=92?= =?UTF-8?q?=E5=8F=96=E5=BE=97=E3=81=99=E3=82=8B=E3=82=A8=E3=83=B3=E3=83=89?= =?UTF-8?q?=E3=83=9D=E3=82=A4=E3=83=B3=E3=83=88=E3=82=92=E8=BF=BD=E5=8A=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- typing-server/openapi.yaml | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/typing-server/openapi.yaml b/typing-server/openapi.yaml index 7851ba3..4063725 100644 --- a/typing-server/openapi.yaml +++ b/typing-server/openapi.yaml @@ -119,6 +119,36 @@ paths: "400": description: 不正なリクエストです。 + /scores/{user-id}/current-rank: + get: + tags: + - user + operationId: getMyscoreRanking + summary: ユーザーの現在の順位を取得 + parameters: + - in: path + name: user-id + schema: + type: string + format: uuid + required: true + description: ユーザーID + responses: + "200": + description: ユーザーの現在の順位を返します。 + content: + application/json: + schema: + type: object + properties: + current-rank: + type: integer + description: ユーザーの現在の順位 + "404": + description: ユーザーが見つかりません。 + "500": + description: サーバーエラーが発生しました。 + components: schemas: User: From 6505a72269d172a93d36e253ebe76e8af27bc910 Mon Sep 17 00:00:00 2001 From: shin0729 Date: Fri, 5 Apr 2024 15:19:41 +0900 Subject: [PATCH 2/6] =?UTF-8?q?update:=E3=83=AC=E3=82=B9=E3=83=9D=E3=83=B3?= =?UTF-8?q?=E3=82=B9=E3=81=AB=E3=83=A9=E3=83=B3=E3=82=AD=E3=83=B3=E3=82=B0?= =?UTF-8?q?=E3=81=AE=E5=85=A8=E4=BB=B6=E6=95=B0=E3=82=92=E5=90=AB=E3=82=81?= =?UTF-8?q?=E3=82=8B=E3=82=88=E3=81=86=E3=81=AB=E3=81=97=E3=81=BE=E3=81=97?= =?UTF-8?q?=E3=81=9F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- typing-server/openapi.yaml | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/typing-server/openapi.yaml b/typing-server/openapi.yaml index 4063725..c8f829b 100644 --- a/typing-server/openapi.yaml +++ b/typing-server/openapi.yaml @@ -79,9 +79,15 @@ paths: content: application/json: schema: - type: array - items: - $ref: "#/components/schemas/ScoreRanking" + type: object + properties: + rankings: + type: array + items: + $ref: "#/components/schemas/ScoreRanking" + total_count: + type: integer + description: ランキングの全件数 "400": description: 不正なリクエストです。 From 9db2d124ea219840bba44b0f107a6614e08823f6 Mon Sep 17 00:00:00 2001 From: shin0729 Date: Fri, 5 Apr 2024 06:38:28 +0000 Subject: [PATCH 3/6] generate TS code from api schema --- typing-app/src/libs/api/v1.d.ts | 38 ++++++++++++++++++++++++++++++++- 1 file changed, 37 insertions(+), 1 deletion(-) diff --git a/typing-app/src/libs/api/v1.d.ts b/typing-app/src/libs/api/v1.d.ts index 12d1efb..f1343b0 100644 --- a/typing-app/src/libs/api/v1.d.ts +++ b/typing-app/src/libs/api/v1.d.ts @@ -21,6 +21,10 @@ export interface paths { /** スコアを登録 */ post: operations["registerScore"]; }; + "/scores/{user-id}/current-rank": { + /** ユーザーの現在の順位を取得 */ + get: operations["getMyscoreRanking"]; + }; } export type webhooks = Record; @@ -109,7 +113,11 @@ export interface operations { /** @description スコアランキングを返します。 */ 200: { content: { - "application/json": components["schemas"]["ScoreRanking"][]; + "application/json": { + rankings?: components["schemas"]["ScoreRanking"][]; + /** @description ランキングの全件数 */ + total_count?: number; + }; }; }; /** @description 不正なリクエストです。 */ @@ -149,4 +157,32 @@ export interface operations { }; }; }; + /** ユーザーの現在の順位を取得 */ + getMyscoreRanking: { + parameters: { + path: { + /** @description ユーザーID */ + "user-id": string; + }; + }; + responses: { + /** @description ユーザーの現在の順位を返します。 */ + 200: { + content: { + "application/json": { + /** @description ユーザーの現在の順位 */ + "current-rank"?: number; + }; + }; + }; + /** @description ユーザーが見つかりません。 */ + 404: { + content: never; + }; + /** @description サーバーエラーが発生しました。 */ + 500: { + content: never; + }; + }; + }; } From 6b3841aa60e1ebba54b61378c4eb78b2c6aa387d Mon Sep 17 00:00:00 2001 From: shin0729 Date: Fri, 5 Apr 2024 15:59:06 +0900 Subject: [PATCH 4/6] =?UTF-8?q?update:=E3=83=AC=E3=82=B9=E3=83=9D=E3=83=B3?= =?UTF-8?q?=E3=82=B9=E3=81=ABrequired=E3=82=92=E8=BF=BD=E5=8A=A0=E3=81=97?= =?UTF-8?q?=E3=81=BE=E3=81=97=E3=81=9F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- typing-server/openapi.yaml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/typing-server/openapi.yaml b/typing-server/openapi.yaml index c8f829b..c1fe42b 100644 --- a/typing-server/openapi.yaml +++ b/typing-server/openapi.yaml @@ -88,6 +88,9 @@ paths: total_count: type: integer description: ランキングの全件数 + required: + - rankings + - total_count "400": description: 不正なリクエストです。 @@ -150,6 +153,8 @@ paths: current-rank: type: integer description: ユーザーの現在の順位 + required: + - current-rank "404": description: ユーザーが見つかりません。 "500": From 62bc5e446a0bcc37dd70f7ae36305b16fa413d7e Mon Sep 17 00:00:00 2001 From: shin0729 Date: Fri, 5 Apr 2024 06:59:53 +0000 Subject: [PATCH 5/6] generate TS code from api schema --- typing-app/src/libs/api/v1.d.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/typing-app/src/libs/api/v1.d.ts b/typing-app/src/libs/api/v1.d.ts index f1343b0..e439702 100644 --- a/typing-app/src/libs/api/v1.d.ts +++ b/typing-app/src/libs/api/v1.d.ts @@ -114,9 +114,9 @@ export interface operations { 200: { content: { "application/json": { - rankings?: components["schemas"]["ScoreRanking"][]; + rankings: components["schemas"]["ScoreRanking"][]; /** @description ランキングの全件数 */ - total_count?: number; + total_count: number; }; }; }; @@ -171,7 +171,7 @@ export interface operations { content: { "application/json": { /** @description ユーザーの現在の順位 */ - "current-rank"?: number; + "current-rank": number; }; }; }; From 3c48b2197cf8ab673086015763c6da0db798a4da Mon Sep 17 00:00:00 2001 From: shin0729 Date: Fri, 5 Apr 2024 16:06:54 +0900 Subject: [PATCH 6/6] =?UTF-8?q?chore:=E3=82=A4=E3=83=B3=E3=83=87=E3=83=B3?= =?UTF-8?q?=E3=83=88=E3=82=92=E3=81=82=E3=81=91=E3=81=BE=E3=81=97=E3=81=9F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- typing-server/openapi.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/typing-server/openapi.yaml b/typing-server/openapi.yaml index c1fe42b..b428c6b 100644 --- a/typing-server/openapi.yaml +++ b/typing-server/openapi.yaml @@ -89,8 +89,8 @@ paths: type: integer description: ランキングの全件数 required: - - rankings - - total_count + - rankings + - total_count "400": description: 不正なリクエストです。