We've successfully implemented OpenAPI documentation for the CodeQual API, providing comprehensive API reference documentation for developers.
- Location:
/apps/api/openapi.yaml - Format: OpenAPI 3.0.0
- Coverage: All public v1 API endpoints
- Features:
- Complete schema definitions
- Request/response examples
- Authentication documentation
- Error response formats
- Rate limiting information
- Endpoints:
/docs- HTML documentation page/docs/openapi.json- JSON specification/api/docs- Alternative path
- File:
/apps/api/src/routes/openapi-docs.ts
Added Swagger/JSDoc annotations to routes:
/apps/api/src/routes/analysis.ts/apps/api/src/routes/result-orchestrator.ts/apps/api/src/routes/api-keys.ts
- Script:
/scripts/generate-api-clients.sh - Generates:
- TypeScript/JavaScript SDK
- Python SDK
- Go SDK
- Ruby SDK
- Java SDK
- Getting Started Guide:
/docs/api/getting-started.md - GitHub Actions Example:
/docs/api/examples/github-actions.yml - Node.js Example:
/docs/api/examples/node-example.ts
securitySchemes:
ApiKeyAuth:
type: apiKey
in: header
name: X-API-Key
description: API key for authentication- POST /v1/analyze-pr - Submit PR for analysis
- GET /v1/analysis/{id}/progress - Check analysis status
- GET /v1/analysis/history - Get analysis history
- GET /v1/reports/{id} - Get detailed reports
- GET /api/keys - List API keys (user auth)
- POST /api/keys - Create API key (user auth)
- DELETE /api/keys/{id} - Revoke API key (user auth)
- GET /api/keys/{id}/usage - Get usage stats (user auth)
- PRAnalysisRequest
- AnalysisResponse
- AnalysisProgress
- AnalysisResults
- Error responses
- Rate limit information
- Access documentation at:
https://api.codequal.com/docs - Get OpenAPI spec:
https://api.codequal.com/docs/openapi.json - Import into Postman/Insomnia for testing
- Generate client SDKs using the provided script
- Documentation auto-updates from code annotations
- Run
npm run generate-clientsto update SDKs - Test endpoints using the OpenAPI spec
- Add Swagger UI: When dependencies are properly installed
- Enhance Examples: Add more language-specific examples
- API Versioning: Implement version management
- Webhook Documentation: Add webhook event schemas
- GraphQL Alternative: Consider GraphQL API option
- Developer Experience: Clear, interactive documentation
- SDK Generation: Automatic client library generation
- Type Safety: Strong typing for requests/responses
- Testing: Import spec into API testing tools
- Consistency: Single source of truth for API