-
Notifications
You must be signed in to change notification settings - Fork 0
Orval integration | Development #10
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
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This pull request adds Orval integration as an optional feature to the Next.js CLI scaffold generator, allowing users to set up API code generation during project initialization. The implementation includes configuration prompts, project scaffolding logic, and an Orval configuration template.
- Added Orval as a configurable option in the project setup prompts
- Implemented automated Orval setup including package installation, config file generation, and package.json script creation
- Version bumped from 2.0.0 to 2.1.0 to reflect the new feature
Reviewed changes
Copilot reviewed 4 out of 6 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| src/templates/orval.ts | Adds Orval configuration template with react-query client and axios mutator setup |
| src/scaffold.ts | Implements setupOrval function and integrates it into the scaffolding workflow; includes code formatting improvements |
| src/prompts.ts | Adds orval boolean option to ProjectConfig interface and includes it in the interactive prompt flow |
| package.json | Bumps CLI version from 2.0.0 to 2.1.0 |
| package-lock.json | Updates lockfile version to match package.json |
| .gitignore | Refines test directory ignore patterns (unrelated to Orval feature) |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| override: { | ||
| mutator: { | ||
| path: './src/lib/axios.ts', | ||
| name: 'backendApi', |
Copilot
AI
Jan 3, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The mutator name 'backendApi' does not match the actual export name from the axios client. The axios client template exports 'api', not 'backendApi'. This will cause Orval to fail when trying to use the mutator. Update the name to 'api' to match the axios client export.
| name: 'backendApi', | |
| name: 'api', |
| await fs.writeFile( | ||
| path.join(projectPath, "orval.config.ts"), | ||
| orvalConfig | ||
| ); |
Copilot
AI
Jan 3, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The setupOrval function doesn't ensure that the target directories exist before writing files. While the root project directory exists, the function should call fs.ensureDir for the directories that will contain generated files (e.g., './src/lib/api'). This follows the pattern used in other setup functions like setupAxios (line 560) and setupForms (lines 970, 973).
| input: 'http://localhost:3000/api/json', | ||
| output: { | ||
| target: './src/lib/api/generated.ts', | ||
| client: 'react-query', |
Copilot
AI
Jan 3, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The Orval configuration specifies 'react-query' as the client, but there's no check to ensure that React Query is actually configured in the project. This could lead to generated code that depends on @tanstack/react-query when it's not installed. Consider either documenting this dependency requirement in the prompt message or adding a conditional check to warn users if they enable Orval without React Query.
This pull request introduces Orval integration as an optional feature in the Next.js CLI scaffold generator. Users can now choose to initialize Orval for API code generation during project setup. The implementation includes prompt updates, project scaffolding logic, and the necessary template for Orval configuration.
Feature: Orval Integration
orvalas a boolean option in theProjectConfiginterface and included it in the initial prompt options. [1] [2]setupOrvalfunction inscaffold.tsto install the Orval dev dependency, generate anorval.config.tsfile, and add agenscript topackage.json. [1] [2]src/templates/orval.ts.Other
2.0.0to2.1.0inpackage.jsonto reflect the new feature.