-
Notifications
You must be signed in to change notification settings - Fork 308
feat(zod-openapi): add defineOpenAPIRoute and openapiRoutes for batch route registration #1752
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
Open
destroSunRay
wants to merge
9
commits into
honojs:main
Choose a base branch
from
destroSunRay:zod-openapi-with-better-compatability-for-rpc-2
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
e904701
feat: add defineOpenAPIRoute and openapiRoutes for enhanced route def…
destroSunRay d2306f8
feat: add validatePost route for input validation and enhance route m…
destroSunRay 7b43986
refactor: remove obsolete test file for OpenAPI routes
destroSunRay 41842d5
docs: add documentation for defineOpenAPIRoute and openapiRoutes
destroSunRay 0a9e7d0
feat: add defineOpenAPIRoute and openapiRoutes for improved route def…
destroSunRay 439cbcb
feat: add defineOpenAPIRoute and openapiRoutes for improved route man…
destroSunRay 4c846b3
refactor: improve route registration logic by filtering out routes wi…
destroSunRay ae04edc
ci: apply automated fixes
autofix-ci[bot] ef67047
remove typecheck error
yusukebe File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,34 @@ | ||
| --- | ||
| '@hono/zod-openapi': minor | ||
| --- | ||
|
|
||
| This PR adds two new utilities to improve route definition and registration in `@hono/zod-openapi`: | ||
|
|
||
| - `defineOpenAPIRoute`: Provides explicit type safety for route definitions | ||
| - `openapiRoutes`: Enables batch registration of multiple routes with full type safety | ||
|
|
||
| - Registering many routes individually was repetitive and verbose | ||
| - Type inference for complex route configurations was challenging | ||
| - Organizing routes across multiple files was difficult | ||
| - No built-in support for conditional route registration | ||
| - RPC type safety was hard to maintain across scattered route registrations | ||
|
|
||
| - `defineOpenAPIRoute`: Wraps route definitions with explicit types for better IDE support and type checking | ||
| - `openapiRoutes`: Accepts an array of route definitions and registers them all at once | ||
| - Supports `addRoute` flag for conditional registration | ||
| - Maintains full type safety and RPC support through recursive type merging | ||
| - Enables clean modular organization of routes | ||
|
|
||
| - ✅ Reduced boilerplate code | ||
| - ✅ Better type inference and IDE autocomplete | ||
| - ✅ Easier code organization and maintainability | ||
| - ✅ Declarative conditional routes | ||
| - ✅ Full backward compatibility | ||
|
|
||
| See the updated README for usage examples. | ||
|
|
||
| - All existing tests pass (102/102) | ||
| - Added tests for new functionality | ||
| - Verified type inference works correctly | ||
|
|
||
| - Updated package README with usage examples |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
README formatting:
const app = new OpenAPIHono()is outside the fencedtscode block, so it will render as plain text and makes the example harder to copy/paste. Move that line into the same ```ts block as theapp.openapiRoutes(...)call (or wrap it in its own code block).