Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: 試合の走行結果の追加のスキーマ定義 #389

Merged
merged 3 commits into from
Oct 4, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion packages/kcms/src/match/adaptor/validator/match.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,13 @@ export const GetMatchIdResponseSchema = PreSchema.or(MainSchema);

export const GetMatchRunResultResponseSchema = z.array(RunResultSchema).max(4);

export const GetMatchRunResultParamsSchema = z.object({
export const GetMatchRunResultRequestSchema = 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);
31 changes: 29 additions & 2 deletions packages/kcms/src/match/routing.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@ import {
GetMatchIdParamsSchema,
GetMatchIdResponseSchema,
GetMatchRunResultResponseSchema,
GetMatchRunResultParamsSchema,
GetMatchRunResultRequestSchema,
PostMatchRunResultRequestSchema,
PostMatchRunResultRequestPathParamsSchema,
} from '../match/adaptor/validator/match';

export const GetMatchRoute = createRoute({
Expand Down Expand Up @@ -84,7 +86,7 @@ export const GetMatchIdRoute = createRoute({
export const GetMatchRunResultRoute = createRoute({
method: 'get',
path: '/match/{matchType}/{matchId}/run_result',
request: { params: GetMatchRunResultParamsSchema },
request: { params: GetMatchRunResultRequestSchema },
Suzune2741 marked this conversation as resolved.
Show resolved Hide resolved
responses: {
200: {
content: {
Expand All @@ -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',
},
},
});