Skip to main content

Overview

TrailBase automatically generates OpenAPI 3.0 specifications for your APIs, providing interactive documentation through Swagger UI and enabling API client generation.

Accessing API Documentation

Swagger UI

Access interactive API documentation at:
The Swagger UI provides:
  • Interactive testing: Try API endpoints directly from the browser
  • Request/response examples: See sample data for each endpoint
  • Authentication: Test authenticated endpoints
  • Schema documentation: Explore data models and types

OpenAPI JSON

Download the raw OpenAPI specification:

API Structure

From crates/core/src/lib.rs:

API Categories

Authentication API

Endpoints under /api/auth/v1:
  • POST /register - Register new user
  • POST /login - Login with email/password
  • POST /logout - Logout current user
  • GET /user - Get current user profile
  • POST /verify_email - Request email verification
  • POST /reset_password - Request password reset
  • GET /oauth/{provider} - OAuth login
  • GET /oauth/{provider}/callback - OAuth callback
  • GET /oauth/providers - List OAuth providers

Records API

Endpoints under /api/records/v1/{table}:
  • GET /{table} - List records
  • POST /{table} - Create record
  • GET /{table}/{id} - Get record by ID
  • PATCH /{table}/{id} - Update record
  • DELETE /{table}/{id} - Delete record
  • GET /files/{id} - Download file

Custom API Documentation

Document Custom Endpoints

Add OpenAPI annotations to your endpoints:

Group Custom APIs

Schema Generation

Derive Schema

Nested Schemas

Response Documentation

Success Responses

Error Responses

Authentication Documentation

Bearer Token

Client Generation

Generate TypeScript Client

Use openapi-typescript:
Usage:

Generate Python Client

Use openapi-python-client:

Generate Go Client

Use oapi-codegen:

Testing with OpenAPI

Validate Responses

Contract Testing

Best Practices

1

Document all endpoints

Add OpenAPI annotations to every public endpoint for complete documentation.
2

Provide examples

Include example requests and responses:
3

Use descriptive tags

Group related endpoints with tags:
4

Document errors

Specify all possible error responses with status codes and error schemas.
5

Keep specs in sync

Run validation tests to ensure OpenAPI specs match implementation.
6

Version your APIs

Use path prefixes for API versioning:

Customizing Swagger UI

The Swagger UI can be customized by modifying the HTML template in the TrailBase source:

Alternative API Documentation

Redoc

Use Redoc for a different documentation style:

RapiDoc

RapiDoc offers a customizable API console:

Next Steps

Custom Endpoints

Build documented APIs

WASM Components

Create custom endpoints

OAuth Providers

Document auth flows

Object Storage

File upload APIs