diff --git a/packages/kcms/src/match/adaptor/validator/match.ts b/packages/kcms/src/match/adaptor/validator/match.ts index 17fcd0c4..84ead4a1 100644 --- a/packages/kcms/src/match/adaptor/validator/match.ts +++ b/packages/kcms/src/match/adaptor/validator/match.ts @@ -77,3 +77,9 @@ export const GetMatchRunResultParamsSchema = z.object({ matchType: MatchTypeSchema, matchId: MatchIdSchema, }); + +export const PostMatchRunResultRequestPathParamsSchema = z.object({ + matchType: z.enum(pick(config.matches, 'type')).openapi({ example: config.matches[0].type }), + id: z.string().openapi({ example: '320984' }), +}); +export const PostMatchRunResultRequestSchema = z.array(RunResultSchema).max(4).min(1); diff --git a/packages/kcms/src/match/routing.ts b/packages/kcms/src/match/routing.ts index 2c8014b9..3db5c82a 100644 --- a/packages/kcms/src/match/routing.ts +++ b/packages/kcms/src/match/routing.ts @@ -7,6 +7,8 @@ import { GetMatchIdParamsSchema, GetMatchIdResponseSchema, GetMatchRunResultResponseSchema, + PostMatchRunResultRequestSchema, + PostMatchRunResultRequestPathParamsSchema, GetMatchRunResultParamsSchema, } from '../match/adaptor/validator/match'; @@ -104,3 +106,28 @@ export const GetMatchRunResultRoute = createRoute({ }, }, }); +export const PostMatchRunResultRoute = createRoute({ + method: 'post', + path: '/match/{matchType}/{id}/run_result', + request: { + params: PostMatchRunResultRequestPathParamsSchema, + body: { + content: { + 'application/json': { schema: PostMatchRunResultRequestSchema }, + }, + }, + }, + responses: { + 200: { + description: 'Post run result', + }, + 400: { + content: { + 'application/json': { + schema: CommonErrorSchema, + }, + }, + description: 'Common error', + }, + }, +});