Open API

Generate an OpenAPI schema for auth endpoints.

This page documents the current Ruby port behavior. Ruby uses snake_case option names and auth.api method names; HTTP paths and JSON keys keep the upstream wire shape where implemented.

Configure

config/auth.rb
require "better_auth"

auth = BetterAuth.auth(
  secret: ENV.fetch("BETTER_AUTH_SECRET"),
  base_url: ENV.fetch("BETTER_AUTH_URL", "http://localhost:3000"),
  plugins: [
    BetterAuth::Plugins.open_api
  ]
)

Usage

server.rb
schema = auth.api.generate_open_api_schema

status, headers, body = auth.api.open_api_reference(as_response: true)

Routes

MethodPathRuby API method
GET/open-api/generate-schemaauth.api.generate_open_api_schema
GET/referenceauth.api.open_api_reference

Options

Current Ruby options accepted by BetterAuth::Plugins.open_api:

  • path
  • disable_default_reference
  • nonce
  • theme

Support Notes

  • The examples above are based on Ruby plugin source and tests in packages/better_auth.
  • The generated document includes upstream base-route inventory, rich request and response schemas, model schemas, security schemes, path/query parameters, visible Ruby plugin endpoints, and Scalar reference configuration.
  • Ruby intentionally omits its callable /set-password extension from generated OpenAPI because upstream Better Auth v1.6.9 has no public OpenAPI path for that server API.

On this page