[PR #7150] [MERGED] fix(open-api): correctly infer type for ZodDefault fields #15351

Closed
opened 2026-04-13 09:59:05 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/better-auth/better-auth/pull/7150
Author: @MuzzaiyyanHussain
Created: 1/6/2026
Status: Merged
Merged: 1/8/2026
Merged by: @bytaesu

Base: canaryHead: fix/openapi-zoddefault


📝 Commits (6)

  • 3100b9b fix(open-api): unwrap ZodDefault to infer correct schema types
  • 30da504 Merge branch 'canary' into fix/openapi-zoddefault
  • a63fdd8 test: add ZodDefault and inner type test case
  • a9c9200 fix: correct ZodDefault handling
  • 5063711 test: update snapshots
  • 06f5da1 test: improve test code

📊 Changes

3 files changed (+79 additions, -3 deletions)

View changed files

📝 packages/better-auth/src/plugins/open-api/__snapshots__/open-api.test.ts.snap (+3 -2)
📝 packages/better-auth/src/plugins/open-api/generator.ts (+19 -1)
📝 packages/better-auth/src/plugins/open-api/open-api.test.ts (+57 -0)

📄 Description

Fixes incorrect OpenAPI type inference for fields wrapped in ZodDefault, ensuring rememberMe and similar fields are generated with the correct type.
tests relevant to this change have passed locally.

fixes #7127


Summary by cubic

Correctly infers OpenAPI types for fields wrapped in ZodDefault and includes their default values, so fields like rememberMe are generated as boolean with default: true. Fixes #7127.

  • Bug Fixes
    • Unwrap ZodDefault during schema generation to infer the inner type and emit the default value, preventing string fallback for defaulted fields.

Written for commit 06f5da16eb. Summary will update on new commits.


🔄 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/7150 **Author:** [@MuzzaiyyanHussain](https://github.com/MuzzaiyyanHussain) **Created:** 1/6/2026 **Status:** ✅ Merged **Merged:** 1/8/2026 **Merged by:** [@bytaesu](https://github.com/bytaesu) **Base:** `canary` ← **Head:** `fix/openapi-zoddefault` --- ### 📝 Commits (6) - [`3100b9b`](https://github.com/better-auth/better-auth/commit/3100b9bf014527b2ed162814b822dc885277252a) fix(open-api): unwrap ZodDefault to infer correct schema types - [`30da504`](https://github.com/better-auth/better-auth/commit/30da504e86d0b1bfe6d6483f512dc70e3e8cfdc3) Merge branch 'canary' into fix/openapi-zoddefault - [`a63fdd8`](https://github.com/better-auth/better-auth/commit/a63fdd8ca562e2e263e39706966c78ddbe45a2fd) test: add ZodDefault and inner type test case - [`a9c9200`](https://github.com/better-auth/better-auth/commit/a9c9200aacec8c2dfcd15c8d94dc4e69172b41cc) fix: correct ZodDefault handling - [`5063711`](https://github.com/better-auth/better-auth/commit/506371166b728816aa323513c215ec86f0d5e8d8) test: update snapshots - [`06f5da1`](https://github.com/better-auth/better-auth/commit/06f5da16ebb1b18282bedf3a148b57181ec0444f) test: improve test code ### 📊 Changes **3 files changed** (+79 additions, -3 deletions) <details> <summary>View changed files</summary> 📝 `packages/better-auth/src/plugins/open-api/__snapshots__/open-api.test.ts.snap` (+3 -2) 📝 `packages/better-auth/src/plugins/open-api/generator.ts` (+19 -1) 📝 `packages/better-auth/src/plugins/open-api/open-api.test.ts` (+57 -0) </details> ### 📄 Description Fixes incorrect OpenAPI type inference for fields wrapped in ZodDefault, ensuring `rememberMe` and similar fields are generated with the correct type. tests relevant to this change have passed locally. fixes #7127 <!-- This is an auto-generated description by cubic. --> --- ## Summary by cubic Correctly infers OpenAPI types for fields wrapped in ZodDefault and includes their default values, so fields like rememberMe are generated as boolean with default: true. Fixes #7127. - **Bug Fixes** - Unwrap ZodDefault during schema generation to infer the inner type and emit the default value, preventing string fallback for defaulted fields. <sup>Written for commit 06f5da16ebb1b18282bedf3a148b57181ec0444f. Summary will update on new commits.</sup> <!-- End of auto-generated description by cubic. --> --- <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-13 09:59:05 -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#15351