fix(server-hono): support Zod v4 records in Swagger docs#1220
Conversation
🦋 Changeset detectedLatest commit: 0751299 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (3)
📝 WalkthroughWalkthroughThis pull request fixes Swagger/OpenAPI generation for Zod v4 record schemas by updating route schemas to use explicit key-value record types ( Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Possibly related PRs
Poem
🚥 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 |
PR Checklist
Please check if your PR fulfills the following requirements:
Bugs / Features
What is the current behavior?
Swagger/OpenAPI generation can fail under Zod v4 for the built-in tool routes. The tool route schemas used single-argument
z.record(z.any()), which Zod v4 treats differently and leaves the record value type undefined. The vendored OpenAPI generator then throwsCannot use 'in' operator to search for 'def' in undefinedwhen/docis requested by Swagger UI.What is the new behavior?
The built-in tool route schemas now use explicit record key and value schemas via
z.record(z.string(), z.any()), which works with both Zod v3 and Zod v4. Added coverage for built-in tool route OpenAPI docs and a Zod v4 record-schema OpenAPI regression test.fixes Zod v4 Swagger UI crash for built-in tool route schemas
Notes for reviewers
Validated with:
pnpm --filter @voltagent/server-hono test -- --runpnpm biome check packages/server-hono/src/routes/tool.routes.ts packages/server-hono/src/app-factory.spec.tspnpm --filter @voltagent/server-hono buildzod@4.3.6OpenAPI generation checkpnpm --filter @voltagent/server-hono typecheckcurrently fails in this checkout on pre-existing Hono typed-response/status-code route errors outside this change.Summary by cubic
Fixes Swagger/OpenAPI generation crash under Zod v4 for built-in tool routes in
@voltagent/server-hono./docnow renders correctly with Zod v3 and v4.parametersandcontextnow usez.record(z.string(), z.any())instead ofz.record(z.any()).OpenApiGeneratorV31./docerror: Cannot use 'in' operator to search for 'def' in undefined.Written for commit 0751299. Summary will update on new commits.
Summary by CodeRabbit
Bug Fixes
Tests