OpenAPI Quick Reference
OpenAPI Quick Reference
Quick commands and workflows for working with the OpenAPI specification.
🚀 Quick Start
# Validate specdeno task openapi:validate
# Generate docsdeno task openapi:docs
# Run contract testsdeno task test:contract
# View generated docsopen docs/api/index.html📋 Common Tasks
Before Committing
# Validate OpenAPI specdeno task openapi:validate
# Run all testsdeno task test
# Run contract testsdeno task test:contractBefore Deploying
# Full validation pipelinedeno task openapi:validate && \deno task openapi:docs && \deno task test:contract
# Deploydeno task wrangler:deployTesting Specific Endpoints
# Test sync compilationdeno test --filter "Contract: POST /compile" worker/openapi-contract.test.ts --allow-read --allow-write --allow-net --allow-env
# Test async queuedeno test --filter "Contract: POST /compile/async" worker/openapi-contract.test.ts --allow-read --allow-write --allow-net --allow-env
# Test streamingdeno test --filter "Contract: POST /compile/stream" worker/openapi-contract.test.ts --allow-read --allow-write --allow-net --allow-env🔄 Async Queue Operations
Key Concepts
Cloudflare Queues are used for:
- Long-running compilations (>5 seconds)
- Batch operations
- Background processing
- Rate limit avoidance
Queue Workflow
1. POST /compile/async → Returns 202 + requestId2. Job processes in background3. GET /queue/results/{requestId} → Returns results4. GET /queue/stats → Monitor queue healthTesting Queues
# Test queue functionalitydeno test --filter "Queue" worker/openapi-contract.test.ts --allow-read --allow-write --allow-net --allow-env
# Note: Local tests may return 500 (queue not configured)# This is expected - queues work in productionQueue Configuration
In wrangler.toml:
[[queues.producers]]queue = "bloqr-backend-worker-queue"binding = "BLOQR_BACKEND_QUEUE"
[[queues.producers]]queue = "bloqr-backend-worker-queue-high-priority"binding = "BLOQR_BACKEND_QUEUE_HIGH_PRIORITY"
[[queues.consumers]]queue = "bloqr-backend-worker-queue"max_batch_size = 10max_batch_timeout = 30📊 Response Codes
Success Codes
200- OK (sync operations)202- Accepted (async operations queued)
Client Error Codes
400- Bad Request (invalid input, batch limit exceeded)404- Not Found (queue result not found)429- Rate Limited
Server Error Codes
500- Internal Error (validation failed, queue unavailable)
📝 Schema Validation
Request Validation
All requests are validated against OpenAPI schemas:
{ "configuration": { "name": "Required string", "sources": [ { "source": "Required string" } ] }}Response Validation
Contract tests verify:
- ✅ Status codes match spec
- ✅ Content-Type headers correct
- ✅ Required fields present
- ✅ Data types match
- ✅ Custom headers (X-Cache, X-Request-Deduplication)
🧪 Postman Testing
# Regenerate collection from OpenAPI specdeno task postman:collection
# Run all Postman testsnewman run docs/postman/postman-collection.json -e docs/postman/postman-environment.json
# Run specific foldernewman run docs/postman/postman-collection.json -e docs/postman/postman-environment.json --folder "Compilation"
# With detailed reportingnewman run docs/postman/postman-collection.json -e docs/postman/postman-environment.json --reporters cli,json,html📈 Monitoring
Queue Metrics
# Get queue statisticscurl http://localhost:8787/queue/stats
# Response:{ "pending": 0, "completed": 42, "failed": 1, "cancelled": 0, "totalProcessingTime": 12500, "averageProcessingTime": 297, "processingRate": 8.4, "queueLag": 150}Performance Metrics
# Get API metricscurl http://localhost:8787/metrics
# Response shows:# - Request counts per endpoint# - Success/failure rates# - Average durations# - Error types🐛 Troubleshooting
Validation Errors
❌ Missing "operationId" for POST /compile→ Add operationId to endpoint in docs/api/openapi.yaml
Contract Test Failures
❌ Expected status 200, got 500→ Check server logs, verify request matches schema
Queue Always Returns 500
❌ Queue bindings are not available→ Expected locally. Queues work in production with Cloudflare Workers
Documentation Won’t Generate
❌ Failed to parse YAML→ Run deno task openapi:validate to check syntax
📚 File Locations
docs/api/openapi.yaml # OpenAPI specification (canonical source — edit this)docs/api/cloudflare-schema.yaml # Auto-generated (deno task schema:cloudflare)docs/postman/postman-collection.json # Auto-generated (deno task postman:collection)docs/postman/postman-environment.json # Auto-generated (deno task postman:collection)scripts/validate-openapi.ts # Validation scriptscripts/generate-docs.ts # Documentation generatorscripts/generate-postman-collection.ts # Postman generatorworker/openapi-contract.test.ts # Contract testsdocs/api/index.html # Generated HTML docsdocs/api/README.md # Generated markdown docsdocs/api/OPENAPI_TOOLING.md # Complete guidedocs/postman/README.md # Postman collection guidedocs/testing/POSTMAN_TESTING.md # Postman testing guide🔗 Links
- OpenAPI Spec: openapi.yaml
- Complete Guide: OPENAPI_TOOLING.md
- Postman Guide: POSTMAN_TESTING.md
- Queue Guide: QUEUE_SUPPORT.md
- Generated Docs: index.html
💡 Tips
-
Always validate before committing:
Terminal window deno task openapi:validate -
Test against local server first:
Terminal window deno task dev &sleep 3deno task test:contract -
Update docs when changing endpoints:
Terminal window # Edit docs/api/openapi.yamldeno task openapi:docsgit add docs/api/ -
Use queue for long operations:
- Synchronous:
POST /compile(< 5 seconds) - Asynchronous:
POST /compile/async(> 5 seconds)
- Synchronous:
-
Monitor queue health:
Terminal window watch -n 5 'curl -s http://localhost:8787/queue/stats | jq'
For detailed information, see OPENAPI_TOOLING.md