OpenAPI Quick Reference
Quick reference guide for DataBridge OpenAPI features, Swagger UI commands, and common workflows
OpenAPI Quick Reference
Common Commands
# Generate OpenAPI spec
databridge generate
# View spec location
cat src/openapi.json
# Start server with Swagger UI
npm run dev
# Visit Swagger UI
open http://localhost:3000/docs
# Download spec
curl http://localhost:3000/openapi.json > api-spec.json
URL Endpoints
| Endpoint | Purpose |
|---|---|
/docs | Swagger UI - Interactive API documentation |
/openapi.json | OpenAPI 3.0 specification (downloadable) |
/health | Health check endpoint |
/metrics | Server metrics |
Configuration
Enable/Disable OpenAPI
In .databridge.json:
{
"api": {
"openapi": {
"enabled": true // Set to false to disable
}
}
}
Custom Swagger UI Path
{
"api": {
"openapi": {
"ui": {
"swaggerUI": {
"enabled": true,
"path": "/api-docs" // Default is /docs
}
}
}
}
}
Multiple Servers
{
"api": {
"openapi": {
"servers": [
{ "url": "http://localhost:3000", "description": "Local" },
{ "url": "https://staging.api.com", "description": "Staging" },
{ "url": "https://api.com", "description": "Production" }
]
}
}
}
Generated Files
src/
├── openapi.json ← OpenAPI 3.0 specification
├── plugins/
│ ├── prisma.ts
│ └── swagger.ts ← Swagger UI plugin
├── routes/
│ ├── user.ts
│ ├── product.ts
│ └── _generated.ts
└── index.ts
Swagger UI Features
Testing Endpoints
- Expand endpoint (click on it)
- Click “Try it out”
- Fill in parameters
- Click “Execute”
- View response
Filtering
- Click filter icon (funnel)
- Type to search:
user,POST,create, etc.
Copying Requests
- Click “Try it out”
- Fill parameters
- Copy the “curl” command
- Use in terminal or scripts
Import to Tools
Postman
Import → Link → http://localhost:3000/openapi.json
Insomnia
Import/Export → From URL → http://localhost:3000/openapi.json
VS Code REST Client
- Install REST Client extension
- Create
api-tests.http:@baseUrl = http://localhost:3000 ### Get all users GET {{baseUrl}}/user ### Create user POST {{baseUrl}}/user Content-Type: application/json { "name": "John Doe", "email": "john@example.com" }
Spec Structure
{
"openapi": "3.0.0",
"info": {
"title": "DataBridge API",
"version": "1.0.0"
},
"servers": [...],
"paths": {
"/user": {
"get": { ... },
"post": { ... }
},
"/user/{id}": {
"get": { ... },
"put": { ... },
"delete": { ... }
}
},
"components": {
"schemas": {
"User": { ... },
"CreateUserDTO": { ... },
"UpdateUserDTO": { ... }
}
}
}
Common Operations
List All (GET)
GET /user?page=1&limit=10
Query params:
page- Page number (default: 1)limit- Items per page (max: 100)
Get By ID (GET)
GET /user/123
Create (POST)
POST /user
Content-Type: application/json
{
"name": "John Doe",
"email": "john@example.com"
}
Update (PUT)
PUT /user/123
Content-Type: application/json
{
"name": "Jane Doe"
}
Delete (DELETE)
DELETE /user/123
Response Codes
| Code | Meaning |
|---|---|
| 200 | Success (GET, PUT) |
| 201 | Created (POST) |
| 204 | No Content (DELETE) |
| 400 | Bad Request (validation error) |
| 404 | Not Found |
| 500 | Internal Server Error |
Schema Types
| Prisma Type | OpenAPI Type | Format |
|---|---|---|
| String | string | - |
| Int | integer | int32 |
| BigInt | integer | int64 |
| Float | number | float |
| Decimal | number | double |
| Boolean | boolean | - |
| DateTime | string | date-time |
| Json | object | - |
Next Steps
- Full Tutorial - Complete guide
- API Testing - Contract testing with Dredd
- SDK Generation - Multi-language clients
Need help? Check the full OpenAPI tutorial
Was this page helpful?
Thank you for your feedback!