Conversation
…ending operations - Allow overriding auto-generated operationId in route configuration - Accept route.spec as callback function for extending operation objects - Enable dynamic modification of OpenAPI operation specifications
|
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
WalkthroughThis change extends the Changes
Sequence Diagram(s)sequenceDiagram
participant User
participant Route
participant OpenAPIGenerator
User->>Route: Define route with optional operationId and spec (object or function)
Route->>OpenAPIGenerator: Pass route definition
OpenAPIGenerator->>OpenAPIGenerator: If spec is object, use as operation object
OpenAPIGenerator->>OpenAPIGenerator: If spec is function, call with current operation object
OpenAPIGenerator-->>User: Return generated OpenAPI operation with correct operationId and extensions
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~15 minutes Possibly related PRs
Suggested labels
Poem
Note ⚡️ Unit Test Generation is now available in beta!Learn more here, or try it out under "Finishing Touches" below. 📜 Recent review detailsConfiguration used: CodeRabbit UI 📒 Files selected for processing (4)
🧰 Additional context used🧬 Code Graph Analysis (1)packages/openapi/src/openapi-generator.ts (1)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (3)
🔇 Additional comments (10)
✨ Finishing Touches
🧪 Generate unit tests
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. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Summary of Changes
Hello @unnoq, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!
This pull request significantly enhances the OpenAPI generation capabilities by introducing more granular control over how operation specifications are defined. It allows developers to explicitly set operationId values and dynamically modify the generated OpenAPI operation objects using a callback function, providing greater flexibility and customization for API documentation.
Highlights
- OpenAPI Customization: Introduced the ability to explicitly define
operationIdwithin route configurations, allowing developers to override the auto-generated values for better control over OpenAPI documentation. - Dynamic Spec Modification: Enabled the
route.specproperty to accept a callback function. This allows for dynamic and programmatic extension or modification of the OpenAPI operation object during generation, providing greater flexibility for complex scenarios. - Documentation & Testing: Updated the OpenAPI documentation with clear examples for the new
operationIdoverride andspeccallback features, and added comprehensive test cases to ensure their correct implementation and behavior.
Using Gemini Code Assist
The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.
Invoking Gemini
You can request assistance from Gemini at any point in your pull request via creating an issue comment (i.e. comment on the pull request page) using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands.
| Feature | Command | Description |
|---|---|---|
| Code Review | /gemini review |
Performs a code review for the current pull request in its current state. |
| Pull Request Summary | /gemini summary |
Provides a summary of the current pull request in its current state. |
| Comment | @gemini-code-assist | Responds in comments when explicitly tagged, both in issue comments and review comments. |
| Help | /gemini help |
Displays a list of available commands. |
Customization
To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.
Limitations & Feedback
Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments or fill out our survey to provide feedback.
You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.
Footnotes
-
Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution. ↩
There was a problem hiding this comment.
Pull Request Overview
This PR enhances OpenAPI operation configuration by allowing dynamic customization of operation IDs and specifications. It enables developers to override auto-generated operation IDs and use callback functions to extend operation objects with custom properties like security configurations.
- Add
operationIdfield to route configuration for overriding auto-generated values - Support callback functions in
route.specfor dynamic operation object extension - Update OpenAPI generator to handle both static and callback-based specifications
Reviewed Changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| packages/contract/src/route.ts | Adds operationId field and updates spec type to support callback functions |
| packages/openapi/src/openapi-generator.ts | Implements logic to handle custom operation IDs and callback-based spec extensions |
| packages/openapi/src/openapi-generator.test.ts | Adds test cases for custom operation ID and callback spec functionality |
| apps/content/docs/openapi/openapi-specification.md | Updates documentation with examples of new features |
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
There was a problem hiding this comment.
Code Review
This pull request introduces the ability to override operationId and use a callback function for spec to extend operation objects, enhancing OpenAPI specification generation. A potential issue was identified in packages/openapi/src/openapi-generator.ts regarding the handling of null values for the spec property, and a code suggestion has been provided to address it.
More templates
@orpc/arktype
@orpc/client
@orpc/contract
@orpc/experimental-durable-event-iterator
@orpc/hey-api
@orpc/json-schema
@orpc/nest
@orpc/openapi
@orpc/openapi-client
@orpc/react
@orpc/react-query
@orpc/server
@orpc/shared
@orpc/solid-query
@orpc/standard-server
@orpc/standard-server-aws-lambda
@orpc/standard-server-fetch
@orpc/standard-server-node
@orpc/standard-server-peer
@orpc/svelte-query
@orpc/tanstack-query
@orpc/trpc
@orpc/valibot
@orpc/vue-colada
@orpc/vue-query
@orpc/zod
commit: |
Summary by CodeRabbit
New Features
Documentation
Tests