[PR #4489] [MERGED] fix: properly generate OpenAPI schema for nested ZodObject and ZodOptional #22309

Closed
opened 2026-04-15 20:57:20 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/better-auth/better-auth/pull/4489
Author: @Kinfe123
Created: 9/6/2025
Status: Merged
Merged: 9/6/2025
Merged by: @Kinfe123

Base: canaryHead: fix/openapi-nested-object-schema-generation


📝 Commits (3)

  • f66d964 fix: properly generate OpenAPI schema for nested ZodObject and ZodOptionals
  • b28efe6 lint
  • 9407982 update

📊 Changes

2 files changed (+75 additions, -6 deletions)

View changed files

📝 packages/better-auth/src/plugins/open-api/generator.ts (+44 -6)
📝 packages/better-auth/src/plugins/open-api/open-api.test.ts (+31 -0)

📄 Description

closes #4485
Fixes OpenAPI schema generation to properly handle nested Zod objects as well ZodOptional after zod upgrade by recursively processing object properties instead of treating them as simple types. This resolves the issue where the idToken field was incorrectly documented as a string instead of an object with nested properties (token, accessToken, refreshToken).
before
Screenshot 2025-09-06 at 8 56 32 PM
after
Screenshot 2025-09-06 at 8 56 13 PM


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/better-auth/better-auth/pull/4489 **Author:** [@Kinfe123](https://github.com/Kinfe123) **Created:** 9/6/2025 **Status:** ✅ Merged **Merged:** 9/6/2025 **Merged by:** [@Kinfe123](https://github.com/Kinfe123) **Base:** `canary` ← **Head:** `fix/openapi-nested-object-schema-generation` --- ### 📝 Commits (3) - [`f66d964`](https://github.com/better-auth/better-auth/commit/f66d9646b8f4260124b67de669e74ba1949dbb94) fix: properly generate OpenAPI schema for nested ZodObject and ZodOptionals - [`b28efe6`](https://github.com/better-auth/better-auth/commit/b28efe6dffc97e45eb3225ded5b4a5d2de0170e9) lint - [`9407982`](https://github.com/better-auth/better-auth/commit/9407982a0db40b8c25fecb5a2dee3ce9e164ea32) update ### 📊 Changes **2 files changed** (+75 additions, -6 deletions) <details> <summary>View changed files</summary> 📝 `packages/better-auth/src/plugins/open-api/generator.ts` (+44 -6) 📝 `packages/better-auth/src/plugins/open-api/open-api.test.ts` (+31 -0) </details> ### 📄 Description closes #4485 Fixes OpenAPI schema generation to properly handle nested Zod objects as well ZodOptional after zod upgrade by recursively processing object properties instead of treating them as simple types. This resolves the issue where the idToken field was incorrectly documented as a string instead of an object with nested properties (token, accessToken, refreshToken). before <img width="631" height="438" alt="Screenshot 2025-09-06 at 8 56 32 PM" src="https://github.com/user-attachments/assets/aa00b3f1-b90f-4d27-8ae1-caf52ab43393" /> after <img width="615" height="595" alt="Screenshot 2025-09-06 at 8 56 13 PM" src="https://github.com/user-attachments/assets/dfd7501c-f174-4e0b-bda1-8db73a36b7dd" /> --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
GiteaMirror added the pull-request label 2026-04-15 20:57:20 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/better-auth#22309