aitesting
v1.1.0
Published
AI-powered API testing & documentation generator with OpenAPI/Swagger support
Downloads
112
Maintainers
Readme
🚀 AITesting - Complete API Testing & Documentation Suite
An AI-powered CLI tool that automatically generates Postman collections, API documentation, test files, and live endpoint testing from your backend codebase.
✨ Features
- 🔍 Route Scanning - Automatically discovers all API routes from TypeScript files
- 🧪 Live Endpoint Testing - Makes REAL HTTP requests and records actual responses
- 🔐 Auth Detection - Automatically detects login endpoints and manages JWT tokens
- 📋 Schema Detection - Finds Zod, Joi, and class-validator schemas
- 📁 Postman Collections - Generates organized collections with example responses
- 🌍 Environment Files - Creates local & production Postman environments
- 🧪 Test Generation - Generates Bun test files for all routes
- 📜 OpenAPI/Swagger - Generates OpenAPI 3.0 spec with interactive Swagger UI
- 📚 Enhanced Documentation - Creates comprehensive markdown API docs
- 📊 Test Reports - Saves detailed live test results in JSON format
🛠️ Installation
Install Globally (Recommended)
cd /Users/devx/Desktop/AITESTING
bun linkNow use aitesting command from anywhere!
Or Run Locally
cd /Users/devx/Desktop/AITESTING
bun install📖 Usage
Simple Mode (Just scan and generate Postman collection)
aitesting --path /path/to/your/backendComplete Mode (Everything!)
aitesting --path /path/to/your/backend --allWith Remote Backend
aitesting --path /path/to/backend --all --url https://api.yourapp.comSpecify Output Directory
aitesting --path /backend --all -o ~/Documents/api-docsThe --all flag runs the complete workflow:
- ✅ Scans backend for routes
- ✅ Detects authentication endpoints
- ✅ Finds validation schemas
- ✅ Tests all endpoints live
- ✅ Captures JWT tokens automatically
- ✅ Generates Postman collection with example responses
- ✅ Creates environment files
- ✅ Generates automated test files
- ✅ Creates enhanced documentation
📦 Generated Files
When you run with --all, you'll get:
📁 Project Root
├── postman_collection.json # Postman collection with examples
├── local_environment.postman_environment.json
├── production_environment.postman_environment.json
├── openapi.json # OpenAPI 3.0 specification
├── api-docs.html # Swagger UI (open in browser!)
├── API_DOCUMENTATION.md # Markdown API docs
├── .aitesting/
│ └── report.json # Live test results
└── tests/auto/
├── users.test.ts # Auto-generated tests
├── auth.test.ts
└── ...🎯 What It Does
1. Route Discovery
Scans your TypeScript files using AST parsing to find all route definitions:
router.get("/users/:id", handler);
router.post("/auth/login", handler);2. Live Testing (REAL HTTP Requests!)
⚠️ Makes actual HTTP requests to your backend:
- Tests each endpoint with real network calls (using
fetch) - Records actual response status codes
- Captures real response bodies
- Saves headers and error messages
- Requires your backend to be running!
3. Auth Handling
- Automatically detects login/auth endpoints
- Obtains JWT tokens during testing
- Injects tokens into subsequent requests
- Adds auth headers to Postman collection
4. Schema Detection
Finds validation schemas in your code:
- Zod schemas (
z.object(...)) - Joi schemas (
Joi.object(...)) - class-validator decorators (
@IsString(), etc.)
5. Test Generation
Creates ready-to-run Bun tests:
import { test, expect, describe } from "bun:test";
describe("Users Routes", () => {
test("GET /users/:id", async () => {
const response = await fetch(`${baseUrl}/users/1`);
expect(response).toBeDefined();
});
});6. OpenAPI/Swagger Generation
Generates industry-standard OpenAPI 3.0 specification:
openapi.json- Complete OpenAPI 3.0 specapi-docs.html- Interactive Swagger UI- Includes auth schemes, request/response examples
- Path parameters, request bodies, responses
- Open
api-docs.htmlin browser for interactive docs!
🔧 Configuration
The tool works out-of-the-box, but you can customize:
- Base URL: Edit the
baseUrlin generated environment files - Auth Token Detection: Supports
token,access_token, andaccessTokenfields - Route Detection: Looks for
router.*patterns in TypeScript files
📋 Requirements
- Bun runtime
- Backend with TypeScript route definitions
- Routes using
router.get(),router.post(), etc. pattern
🚦 Example Output
🚀 AITesting v1.0 - Full Workflow
🔍 Scanning backend in: ./backend
✅ Found 23 routes
🔐 Detected auth endpoint: POST /auth/login
📋 Detected schemas: zod, class-validator
🧪 Running live endpoint tests...
✅ Auth token obtained
✓ GET /users 200
✓ POST /users 201
✓ GET /users/:id 200
✗ DELETE /users/:id 401
📊 Live test report saved to .aitesting/report.json
📁 Generated: postman_collection.json
🌍 Environments generated (local & production)
🧪 Test files generated in tests/auto/
📘 Enhanced documentation generated (API_DOCUMENTATION.md)
✅ Complete! All features executed successfully.📝 Important Notes
Live Testing (with --all flag)
- ⚠️ Requires your backend to be running at
http://localhost:5000(default) - Makes REAL HTTP requests using
fetch()- not mock/sample data! - Path parameters (e.g.,
:id) are replaced with1during testing - Failed tests are recorded in the report but don't stop the workflow
- Responses in
openapi.jsonand Postman collection are actual responses from your API
OpenAPI/Swagger UI
- Open
api-docs.htmlin any browser for interactive documentation - Works offline - Swagger UI loads from CDN
- Can be hosted on any web server for team sharing
🤝 Contributing
This is a productivity tool. Feel free to extend and customize for your needs!
📄 License
See LICENSE file.
