From f7aeedf712a4f10a408ec77dc736a11e67668276 Mon Sep 17 00:00:00 2001 From: Suzune2741 Date: Thu, 3 Oct 2024 17:37:53 +0900 Subject: [PATCH 1/3] =?UTF-8?q?feat:=E8=A9=A6=E5=90=88=E3=81=AE=E8=B5=B0?= =?UTF-8?q?=E8=A1=8C=E7=B5=90=E6=9E=9C=E3=81=AE=E5=8F=96=E5=BE=97=E3=81=AE?= =?UTF-8?q?=E3=82=B9=E3=82=AD=E3=83=BC=E3=83=9E=E5=AE=9A=E7=BE=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../kcms/src/match/adaptor/validator/match.ts | 1 + packages/kcms/src/match/routing.ts | 26 +++++++++++++++++++ 2 files changed, 27 insertions(+) diff --git a/packages/kcms/src/match/adaptor/validator/match.ts b/packages/kcms/src/match/adaptor/validator/match.ts index 5e880609..6e3a2ae9 100644 --- a/packages/kcms/src/match/adaptor/validator/match.ts +++ b/packages/kcms/src/match/adaptor/validator/match.ts @@ -46,3 +46,4 @@ export const GetMatchTypeParamsSchema = z.object({ }); export const GetMatchTypeResponseSchema = PreSchema.or(MainSchema); +export const GetMatchRunResultSchema = RunResultSchema; diff --git a/packages/kcms/src/match/routing.ts b/packages/kcms/src/match/routing.ts index 2dbbfb2d..ab1487da 100644 --- a/packages/kcms/src/match/routing.ts +++ b/packages/kcms/src/match/routing.ts @@ -4,6 +4,7 @@ import { GetMatchResponseSchema, GetMatchTypeParamsSchema, GetMatchTypeResponseSchema, + GetMatchRunResultSchema, } from '../match/adaptor/validator/match'; export const GetMatchRoute = createRoute({ @@ -52,3 +53,28 @@ export const GetMatchTypeRoute = createRoute({ }, }, }); + +export const GetMatchRunResultRoute = createRoute({ + method: 'get', + path: '/match/{matchType}/{matchId}/run_result', + request: { params: GetMatchRunResultSchema }, + responses: { + 200: { + content: { + 'application/json': { + schema: GetMatchRunResultSchema, + }, + }, + description: 'Retrieve run result', + }, + 400: { + content: { + 'application/json': { + schema: CommonErrorSchema, + }, + }, + description: 'Common error', + }, + }, + +}); From 207996abcda0cf2d670e2d6fa24e5baae89c9f46 Mon Sep 17 00:00:00 2001 From: Suzune2741 Date: Thu, 3 Oct 2024 17:41:12 +0900 Subject: [PATCH 2/3] =?UTF-8?q?chore:=20prettierformat=E3=82=92=E3=81=8B?= =?UTF-8?q?=E3=81=91=E3=81=9F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/kcms/src/match/routing.ts | 1 - packages/mock/README.md | 2 ++ 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/packages/kcms/src/match/routing.ts b/packages/kcms/src/match/routing.ts index ab1487da..4c57371d 100644 --- a/packages/kcms/src/match/routing.ts +++ b/packages/kcms/src/match/routing.ts @@ -76,5 +76,4 @@ export const GetMatchRunResultRoute = createRoute({ description: 'Common error', }, }, - }); diff --git a/packages/mock/README.md b/packages/mock/README.md index d61b8d3b..ddea287d 100644 --- a/packages/mock/README.md +++ b/packages/mock/README.md @@ -12,7 +12,9 @@ pnpm install ``` ### 開発用サーバの起動 + kcmsと同時に起動することはできません + ``` pnpm dev ``` From b09bbb3b78f5d55a2ca135bf18c65a3e9c5c959b Mon Sep 17 00:00:00 2001 From: Suzune2741 Date: Thu, 3 Oct 2024 18:03:46 +0900 Subject: [PATCH 3/3] =?UTF-8?q?feat:=20RequestSchema=E3=82=92=E5=AE=9A?= =?UTF-8?q?=E7=BE=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/kcms/src/match/adaptor/validator/match.ts | 9 +++++++-- packages/kcms/src/match/routing.ts | 7 ++++--- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/packages/kcms/src/match/adaptor/validator/match.ts b/packages/kcms/src/match/adaptor/validator/match.ts index 6e3a2ae9..547a81b6 100644 --- a/packages/kcms/src/match/adaptor/validator/match.ts +++ b/packages/kcms/src/match/adaptor/validator/match.ts @@ -1,5 +1,5 @@ import { z } from '@hono/zod-openapi'; - +import { config, pick } from 'config'; export const CommonErrorSchema = z.object({ description: z.string().openapi({ example: '存在しないカテゴリです' }), }); @@ -46,4 +46,9 @@ export const GetMatchTypeParamsSchema = z.object({ }); export const GetMatchTypeResponseSchema = PreSchema.or(MainSchema); -export const GetMatchRunResultSchema = RunResultSchema; +export const GetMatchRunResultResponseSchema = z.array(RunResultSchema).max(4); + +export const GetMatchRunResultRequestSchema = z.object({ + matchType: z.enum(pick(config.matches, 'type')).openapi({ example: config.matches[0].type }), + matchId: z.string().openapi({ example: '320984' }), +}); diff --git a/packages/kcms/src/match/routing.ts b/packages/kcms/src/match/routing.ts index 4c57371d..acb73250 100644 --- a/packages/kcms/src/match/routing.ts +++ b/packages/kcms/src/match/routing.ts @@ -4,7 +4,8 @@ import { GetMatchResponseSchema, GetMatchTypeParamsSchema, GetMatchTypeResponseSchema, - GetMatchRunResultSchema, + GetMatchRunResultResponseSchema, + GetMatchRunResultRequestSchema, } from '../match/adaptor/validator/match'; export const GetMatchRoute = createRoute({ @@ -57,12 +58,12 @@ export const GetMatchTypeRoute = createRoute({ export const GetMatchRunResultRoute = createRoute({ method: 'get', path: '/match/{matchType}/{matchId}/run_result', - request: { params: GetMatchRunResultSchema }, + request: { params: GetMatchRunResultRequestSchema }, responses: { 200: { content: { 'application/json': { - schema: GetMatchRunResultSchema, + schema: GetMatchRunResultResponseSchema, }, }, description: 'Retrieve run result',