| description | tags | category | author | version | |||||
|---|---|---|---|---|---|---|---|---|---|
Analyze project to find API endpoints and generate HTTP request files for each |
|
development |
caggodri |
1.0.0 |
Analyze your project's codebase to identify all API endpoints and automatically generate HTTP request files (.req) for testing each endpoint.
Scan the project to find:
- REST API endpoint definitions
- Route handlers
- API controllers
- OpenAPI/Swagger specifications
Then create organized .req files in .cursor/http/ folder.
Identify the framework and locate API definitions:
- Express/Node.js: Look for
app.get(),app.post(),router.get(), etc. - Next.js: Scan
pages/api/orapp/api/routes - FastAPI/Flask: Find
@app.route()or@router.get()decorators - Spring Boot: Look for
@RestController,@GetMapping,@PostMapping - Django: Check
urls.pyand view functions - OpenAPI/Swagger: Parse
openapi.jsonorswagger.yaml
For each endpoint, gather:
- HTTP Method: GET, POST, PUT, PATCH, DELETE
- Path: Full URL path with parameters
- Parameters: Query params, path params, body
- Headers: Required headers (auth, content-type)
- Description: From comments or docs
Create files in .cursor/http/ with this structure:
File naming convention:
{method}-{resource}.req- Examples:
get-users.req,post-user.req,delete-user-by-id.req
File content template:
### {Endpoint Description}
{METHOD} {{baseUrl}}{path}
Content-Type: application/json
Authorization: Bearer {{token}}
{
"example": "request body if needed"
}Group related endpoints:
.cursor/http/
├── users/
│ ├── get-users.req
│ ├── get-user-by-id.req
│ ├── post-user.req
│ ├── put-user.req
│ └── delete-user.req
├── products/
│ ├── get-products.req
│ └── post-product.req
└── auth/
├── post-login.req
└── post-register.req
Generate .cursor/http/.environments/.env.dev:
baseUrl=http://localhost:3000/api
token=your-dev-token-hereFound endpoints:
// From routes/users.js
router.get('/users', getAllUsers);
router.get('/users/:id', getUserById);
router.post('/users', createUser);
router.put('/users/:id', updateUser);
router.delete('/users/:id', deleteUser);Generated files:
.cursor/http/users/get-users.req:
### Get all users
GET {{baseUrl}}/users
Authorization: Bearer {{token}}.cursor/http/users/get-user-by-id.req:
### Get user by ID
GET {{baseUrl}}/users/123
Authorization: Bearer {{token}}.cursor/http/users/post-user.req:
### Create new user
POST {{baseUrl}}/users
Content-Type: application/json
Authorization: Bearer {{token}}
{
"name": "John Doe",
"email": "john@example.com",
"role": "user"
}- Use Environment Variables: Never hardcode URLs or tokens
- Add Descriptions: Include comments explaining each endpoint
- Example Data: Provide realistic example request bodies
- Group Logically: Organize by resource or feature
- Document Parameters: Add comments for required/optional params
- Include Tests: Add assertions or validation comments
- All endpoints from codebase are included
- File names follow naming convention
- Environment variables are used for baseUrl and tokens
- Request bodies have valid JSON examples
- Headers include required authentication
- Files are organized by resource
- Descriptions are clear and helpful
After generating the files:
- Open any
.reqfile in Cursor - Click "Execute Request" CodeLens above the request
- View response in
.resfile - Switch environments using status bar
- Node.js (Express, Fastify, NestJS)
- Next.js (App Router, Pages Router)
- Python (FastAPI, Flask, Django)
- Java (Spring Boot)
- Ruby (Rails)
- Go (Gin, Echo)
- Any OpenAPI/Swagger specification