型生成スクリプトの設置#240
Conversation
|
Preview (prod) → https://240-prod.rucq-ui-preview.trapti.tech/ |
|
Too much diff to scan? Review this PR in Change Stack to start with the highest-impact changes. No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughWalkthroughOpenAPI スキーマから TypeScript 型定義を生成する処理を改善。カスタム generate-types.js スクリプトで openapi-typescript の出力を加工し、Response 接尾辞を削除してから ChangesOpenAPI型生成パイプラインの改善
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related issues
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@generate-types.js`:
- Around line 39-42: The catch block in generate-types.js currently only logs
the error and removes TEMP_FILE, allowing the process to exit with a success
code; modify the catch for the error handling in the generateTypes flow (the
catch that references TEMP_FILE) to either rethrow the caught error or call
process.exit(1) after performing the existing cleanup to ensure a non-zero exit
code is returned (keep the fs.existsSync(TEMP_FILE) fs.unlinkSync(TEMP_FILE)
cleanup). Ensure the log remains but the process does not silently succeed.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 8ada2688-7d95-4890-bf81-6031c8d79859
📒 Files selected for processing (3)
generate-types.jspackage.jsonsrc/api/schema.d.ts
There was a problem hiding this comment.
Pull request overview
This PR introduces an automated workflow for generating root-level TypeScript type aliases from the rucQ OpenAPI schema, aiming to provide simpler alias names (e.g., Camp instead of CampResponse) and replace the previous pnpm generate:api pipeline.
Changes:
- Add a generation script (
generate-types.js) that runsopenapi-typescriptand post-processes exported*Responseroot type aliases into non-suffixed names. - Update
generate:apiinpackage.jsonto use the new script and format the generatedschema.d.ts. - Update the generated
src/api/schema.d.tsto include many new root-level type aliases.
Reviewed changes
Copilot reviewed 2 out of 3 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| src/api/schema.d.ts | Adds generated root-level type aliases (including *Response → non-suffixed aliases). |
| package.json | Switches generate:api to run the new generator script and format the output file. |
| generate-types.js | Implements the OpenAPI → TypeScript generation plus *Response alias renaming. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| } catch (error) { | ||
| console.error('型定義の生成中にエラーが発生しました:', error) | ||
| if (fs.existsSync(TEMP_FILE)) fs.unlinkSync(TEMP_FILE) | ||
| } |
関連:#239
src/api/schema.d.ts にルートレベルの型エイリアスを自動生成するスクリプト generate-types.ts を追加し、その実行で
pnpm generate:apiを置き換えてみましたこれまで合宿型は
Camp、ユーザー型はUserのようにシンプルな名前の型エイリアスを手動で追加していましたが、openapi-typescript はレスポンス型についてSomeResponseという名前で出力し、これを単にSomeとして出力するオプションは見当たりませんこれを後から
Someという型名に書き換えるスクリプトが generate-types.ts です。schema.d.ts の振る舞いの全容を把握できていないので、副作用の可能性については検討し切れていませんが、ひとまず手元のデータではうまくいきますSummary by CodeRabbit