Skip to content

Commit

Permalink
Merge branch 'develop' into chore/bg-color
Browse files Browse the repository at this point in the history
  • Loading branch information
KinjiKawaguchi authored Mar 29, 2024
2 parents 277f5b9 + d164a11 commit 1eacd69
Show file tree
Hide file tree
Showing 4 changed files with 164 additions and 6 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/deploy-oapi-doc.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
name: Generate / Deploy API docs

on:
pull_request:
type:
- closed
push:
branches:
- develop
paths:
- typing-server/openapi.yaml

Expand Down
9 changes: 6 additions & 3 deletions .github/workflows/generate-oapi-types.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ jobs:
cache: "yarn"
cache-dependency-path: typing-app/yarn.lock
- name: Install Dependencies
working-directory: typing-app
run: yarn
- name: Retrieve the Schema version
uses: mikefarah/yq@master
Expand All @@ -35,9 +36,11 @@ jobs:
SCHEMA_VERSION=${{ steps.get_schema_version.outputs.result }}
SCHEMA_MAJOR_VERSION=${SCHEMA_VERSION%%.*}
npx openapi-typescript ../typing-server/openapi.yaml --output ./src/libs/api/v${SCHEMA_MAJOR_VERSION}.d.ts
- name: Validate
working-directory: typing-app
run: yarn exec tsc --noEmit
# TODO: エラーになるので tsc は一旦やめる
# Error: src/components/atoms/Banner.tsx(3,25): error TS2307: Cannot find module '@/assets/images/banner.png' or its corresponding type declarations.
# - name: Validate
# working-directory: typing-app
# run: yarn exec tsc --noEmit
- name: Commit
uses: stefanzweifel/git-auto-commit-action@v5
with:
Expand Down
152 changes: 152 additions & 0 deletions typing-app/src/libs/api/v1.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,152 @@
/**
* This file was auto-generated by openapi-typescript.
* Do not make direct changes to the file.
*/


export interface paths {
"/health": {
/** サーバーの状態を取得 */
get: operations["healthcheck"];
};
"/users": {
/** ユーザー情報を取得 */
get: operations["getUsers"];
};
"/scores/ranking": {
/** スコアランキングを取得 */
get: operations["getScoresRanking"];
};
"/scores": {
/** スコアを登録 */
post: operations["registerScore"];
};
}

export type webhooks = Record<string, never>;

export interface components {
schemas: {
User: {
id?: string;
student_number?: string;
handle_name?: string;
/** Format: date-time */
created_at?: string;
/** Format: date-time */
updated_at?: string;
};
Score: {
id?: string;
keystrokes?: number;
/** Format: float */
accuracy?: number;
/** Format: date-time */
created_at?: string;
user?: components["schemas"]["User"];
};
ScoreRanking: {
rank?: number;
score?: components["schemas"]["Score"];
};
};
responses: never;
parameters: never;
requestBodies: never;
headers: never;
pathItems: never;
}

export type $defs = Record<string, never>;

export type external = Record<string, never>;

export interface operations {

/** サーバーの状態を取得 */
healthcheck: {
responses: {
/** @description サーバーが正常に稼働しています。 */
200: {
content: never;
};
};
};
/** ユーザー情報を取得 */
getUsers: {
parameters: {
query: {
/** @description 学生番号 */
student_number: string;
};
};
responses: {
/** @description ユーザー情報を返します。 */
200: {
content: {
"application/json": components["schemas"]["User"];
};
};
/** @description ユーザーが見つかりません。 */
404: {
content: never;
};
};
};
/** スコアランキングを取得 */
getScoresRanking: {
parameters: {
query?: {
/** @description ソート対象のカラム */
sort_by?: "keystrokes" | "accuracy";
/** @description ランキングの開始位置(x位 | x>0) */
start?: number;
/** @description ランキングの取得件数 */
limit?: number;
};
};
responses: {
/** @description スコアランキングを返します。 */
200: {
content: {
"application/json": components["schemas"]["ScoreRanking"][];
};
};
/** @description 不正なリクエストです。 */
400: {
content: never;
};
};
};
/** スコアを登録 */
registerScore: {
requestBody: {
content: {
"application/json": {
/**
* Format: uuid
* @description ユーザーID
*/
user_id: string;
/** @description キーストローク数 */
keystrokes: number;
/**
* Format: float
* @description 正確性(ミスタイプ数/ストローク数)
*/
accuracy: number;
};
};
};
responses: {
/** @description スコアが正常に登録されました。 */
201: {
content: never;
};
/** @description 不正なリクエストです。 */
400: {
content: never;
};
};
};
}
3 changes: 3 additions & 0 deletions typing-server/openapi.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
openapi: 3.0.0
info:
title: Typing API
description: >-
This is Typing API
version: 1.0.0
servers:
- url: http://localhost:8080
Expand All @@ -14,6 +16,7 @@ tags:
description: ユーザー関係(仮)
- name: score
description: スコア関係(仮)
title: Sample Pet Store App
paths:
/health:
get:
Expand Down

0 comments on commit 1eacd69

Please sign in to comment.