Open API plugin not working #738

Closed
opened 2026-03-13 08:02:13 -05:00 by GiteaMirror · 1 comment
Owner

Originally created by @SharkGW on GitHub (Feb 24, 2025).

Is this suited for github?

  • Yes, this is suited for github

To Reproduce

When accessing the OpenAPI documentation at http://localhost:8787/api/auth/reference, the webpage loads but fails to display the documentation content in each section. The console shows the following Zod validation error:

ZodError: [
  {
    "code": "invalid_union",
    "unionErrors": [
      {
        "issues": [
          {
            "code": "invalid_type",
            "expected": "string",
            "received": "undefined",
            "path": [
              "selectedSecuritySchemeUids",
              0
            ],
            "message": "Required"
          }
        ],
        "name": "ZodError"
      },
      {
        "issues": [
          {
            "code": "invalid_type", 
            "expected": "array",
            "received": "undefined",
            "path": [
              "selectedSecuritySchemeUids",
              0
            ],
            "message": "Required"
          }
        ],
        "name": "ZodError"
      }
    ],
    "path": [
      "selectedSecuritySchemeUids",
      0
    ],
    "message": "Invalid input"
  }
]

Here’s my current configuration:

import { betterAuth } from "better-auth";
import { db } from "../client";
import { user, session, account, verification } from "../schema";
import { drizzleAdapter } from "better-auth/adapters/drizzle";
import { openAPI } from "better-auth/plugins";
 
export const auth = betterAuth({
    database: drizzleAdapter(db, {
      provider: "pg",
      schema: {
        user,
        session,
        account,
        verification
      }
    }),
    emailAndPassword: {  
      enabled: true
    },
    plugins: [ 
        openAPI(), 
    ]
})

Current vs. Expected behavior

Image Image

What version of Better Auth are you using?

1.1.20

Provide environment information

- OS: MacOS 15.4 Beta
- Browser: Chrome

Which area(s) are affected? (Select all that apply)

Documentation, Backend

Auth config (if applicable)

import { betterAuth } from "better-auth";
import { db } from "../client";
import { user, session, account, verification } from "../schema";
import { drizzleAdapter } from "better-auth/adapters/drizzle";
import { openAPI } from "better-auth/plugins";
 
export const auth = betterAuth({
    database: drizzleAdapter(db, {
      provider: "pg",
      schema: {
        user,
        session,
        account,
        verification
      }
    }),
    emailAndPassword: {  
      enabled: true
    },
    plugins: [ 
        openAPI(), 
    ]
})

Additional context

No response

Originally created by @SharkGW on GitHub (Feb 24, 2025). ### Is this suited for github? - [x] Yes, this is suited for github ### To Reproduce When accessing the OpenAPI documentation at `http://localhost:8787/api/auth/reference`, the webpage loads but fails to display the documentation content in each section. The console shows the following Zod validation error: ``` ZodError: [ { "code": "invalid_union", "unionErrors": [ { "issues": [ { "code": "invalid_type", "expected": "string", "received": "undefined", "path": [ "selectedSecuritySchemeUids", 0 ], "message": "Required" } ], "name": "ZodError" }, { "issues": [ { "code": "invalid_type", "expected": "array", "received": "undefined", "path": [ "selectedSecuritySchemeUids", 0 ], "message": "Required" } ], "name": "ZodError" } ], "path": [ "selectedSecuritySchemeUids", 0 ], "message": "Invalid input" } ] ``` Here’s my current configuration: ```typescript import { betterAuth } from "better-auth"; import { db } from "../client"; import { user, session, account, verification } from "../schema"; import { drizzleAdapter } from "better-auth/adapters/drizzle"; import { openAPI } from "better-auth/plugins"; export const auth = betterAuth({ database: drizzleAdapter(db, { provider: "pg", schema: { user, session, account, verification } }), emailAndPassword: { enabled: true }, plugins: [ openAPI(), ] }) ``` ### Current vs. Expected behavior <img width="1361" alt="Image" src="https://github.com/user-attachments/assets/91ea683f-c689-483e-b57e-6d5fa9e2aa69" /> <img width="1360" alt="Image" src="https://github.com/user-attachments/assets/61cd3389-6ea2-4d75-ba99-61cdcb7dd74c" /> ### What version of Better Auth are you using? 1.1.20 ### Provide environment information ```bash - OS: MacOS 15.4 Beta - Browser: Chrome ``` ### Which area(s) are affected? (Select all that apply) Documentation, Backend ### Auth config (if applicable) ```typescript import { betterAuth } from "better-auth"; import { db } from "../client"; import { user, session, account, verification } from "../schema"; import { drizzleAdapter } from "better-auth/adapters/drizzle"; import { openAPI } from "better-auth/plugins"; export const auth = betterAuth({ database: drizzleAdapter(db, { provider: "pg", schema: { user, session, account, verification } }), emailAndPassword: { enabled: true }, plugins: [ openAPI(), ] }) ``` ### Additional context _No response_
GiteaMirror added the bug label 2026-03-13 08:02:13 -05:00
Author
Owner

@Bekacru commented on GitHub (Feb 24, 2025):

this should be fixed on 1.1.21

@Bekacru commented on GitHub (Feb 24, 2025): this should be fixed on `1.1.21`
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/better-auth#738