Swagger UI Setup for API Testing #
Swagger UI is pre-configured with automatic authentication for local development and Coder workspaces.
Quick Start #
-
Start the development environment
mise run dev -
Access Swagger UI
- Local:
http://localhost:8001 - Coder:
https://swagger-internal--dev--{workspace}--{owner}.coder.internal.gotofu.com
- Local:
-
Test APIs immediately - Authentication credentials are pre-filled! Click “Authorize” to verify.
What’s Pre-Configured #
All authentication headers are automatically injected:
- Cloudflare Access - Auto-injected silently (CF-Access-Client-Id, CF-Access-Client-Secret)
- Admin Key - Pre-filled in Authorize dialog (can be overridden)
- Clerk User ID - Pre-filled from
.config.yamltest credentials - Clerk Org ID - Pre-filled from
.config.yamltest credentials - Coder Workspace URL - Automatically detected and set as default server
Authentication #
Click the “Authorize” button to see pre-filled values:
X-BonsAI-Admin-Key: [auto-filled from .env]
X-BonsAI-Clerk-User-Id: [auto-filled from .config.yaml]
X-BonsAI-Clerk-Organization-Id: [auto-filled from .config.yaml]
You can override any value by editing the field and clicking “Authorize”.
Configuration Files #
Authentication values are loaded from:
.env- Contains BONSAPI_ADMIN_KEY (from Doppler).config.yaml- Contains test Clerk credentials undertestsection:test: clerk_user_id: user_2tU2uWZWPobyhGgNj6QGaZvJjl0 clerk_org_id: org_2yG5SsBiMlSrwDJVBpofU0u8nR5
These are automatically set by override-coder-env.sh when running mise run dev.
Using Different Credentials (Optional) #
To use your own Clerk credentials instead of test credentials:
-
Update
.config.yamlwith your credentials:test: clerk_user_id: your_clerk_user_id clerk_org_id: your_clerk_org_id -
Restart the containers:
docker compose down swagger-ui-internal docker compose up -d swagger-ui-internal
Troubleshooting #
Issue: Getting 401 or 403 errors
- Verify credentials are pre-filled by clicking “Authorize”
- Check that
mise run devcompleted successfully - Ensure
.config.yamlcontains test credentials
Issue: Can’t connect to API
- In Coder: Ensure the server dropdown shows “Current Coder Workspace”
- Local: Select
http://localhost:8080as the server
Issue: Credentials not pre-filled
- Run
./tools/coder/scripts/override-coder-env.sh .envmanually - Restart Swagger UI:
docker compose restart swagger-ui-internal
Advanced: External Webhooks #
To test webhook APIs with external integrations:
-
Start ngrok tunnel:
mise run webhook -
Update
.env:BONSAPI_EXTERNAL_HOST=your-tunnel-url.ngrok-free.app -
Restart services:
docker compose restart bonsapi
Architecture #
The Swagger UI setup uses:
- Docker containers - swagger-ui-internal, swagger-editor, swagger-api (mockoon)
- Dynamic URL injection - Coder workspace URL detected at runtime
- Template processing - Environment variables injected via entrypoint.sh
- Separate interceptor - Authentication headers in interceptor.js (survives codegen)
See tools/swagger/entrypoint.sh and docker-compose.yml for implementation details.