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:試合の走行結果の取得のスキーマ定義をした #383

Merged
merged 4 commits into from
Oct 3, 2024
Merged
Show file tree
Hide file tree
Changes from all 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
@@ -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: '存在しないカテゴリです' }),
});
Expand Down Expand Up @@ -46,3 +46,9 @@ export const GetMatchTypeParamsSchema = z.object({
});

export const GetMatchTypeResponseSchema = PreSchema.or(MainSchema);
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' }),
});
26 changes: 26 additions & 0 deletions packages/kcms/src/match/routing.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ import {
GetMatchResponseSchema,
GetMatchTypeParamsSchema,
GetMatchTypeResponseSchema,
GetMatchRunResultResponseSchema,
GetMatchRunResultRequestSchema,
} from '../match/adaptor/validator/match';

export const GetMatchRoute = createRoute({
Expand Down Expand Up @@ -52,3 +54,27 @@ export const GetMatchTypeRoute = createRoute({
},
},
});

export const GetMatchRunResultRoute = createRoute({
method: 'get',
path: '/match/{matchType}/{matchId}/run_result',
request: { params: GetMatchRunResultRequestSchema },
responses: {
200: {
content: {
'application/json': {
schema: GetMatchRunResultResponseSchema,
},
},
description: 'Retrieve run result',
},
400: {
content: {
'application/json': {
schema: CommonErrorSchema,
},
},
description: 'Common error',
},
},
});
2 changes: 2 additions & 0 deletions packages/mock/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@ pnpm install
```

### 開発用サーバの起動

kcmsと同時に起動することはできません

```
pnpm dev
```
Expand Down