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
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
schema = auth.api.generate_open_api_schema
status, headers, body = auth.api.open_api_reference(as_response: true)Routes
| Method | Path | Ruby API method |
|---|---|---|
GET | /open-api/generate-schema | auth.api.generate_open_api_schema |
GET | /reference | auth.api.open_api_reference |
Options
Current Ruby options accepted by BetterAuth::Plugins.open_api:
pathdisable_default_referencenoncetheme
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-passwordextension from generated OpenAPI because upstream Better Authv1.6.9has no public OpenAPI path for that server API.