Skip to content

Instantly share code, notes, and snippets.

@godrix
Created January 1, 2026 22:27
Show Gist options
  • Select an option

  • Save godrix/f5d70d53cfe9e084f095ccfa48deeac4 to your computer and use it in GitHub Desktop.

Select an option

Save godrix/f5d70d53cfe9e084f095ccfa48deeac4 to your computer and use it in GitHub Desktop.
CursorToys: Command - generate-http-files-from-endpoints (2026-01-01)
{
"cursortoys": {
"version": "1.2.0",
"type": "command",
"created": "2026-01-01T22:27:41.367Z",
"fileCount": 1,
"files": [
{
"name": "generate-http-files-from-endpoints.md",
"type": "command",
"size": 4307
}
]
}
}
description tags category author version
Analyze project to find API endpoints and generate HTTP request files for each
api
http
testing
automation
endpoints
development
caggodri
1.0.0

Generate HTTP Files from Project Endpoints

Analyze your project's codebase to identify all API endpoints and automatically generate HTTP request files (.req) for testing each endpoint.

Objective

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.

Instructions

Step 1: Analyze Project Structure

Identify the framework and locate API definitions:

  • Express/Node.js: Look for app.get(), app.post(), router.get(), etc.
  • Next.js: Scan pages/api/ or app/api/ routes
  • FastAPI/Flask: Find @app.route() or @router.get() decorators
  • Spring Boot: Look for @RestController, @GetMapping, @PostMapping
  • Django: Check urls.py and view functions
  • OpenAPI/Swagger: Parse openapi.json or swagger.yaml

Step 2: Extract Endpoint Information

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

Step 3: Generate HTTP Request Files

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"
}

Step 4: Organize by Resource

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

Step 5: Create Environment File

Generate .cursor/http/.environments/.env.dev:

baseUrl=http://localhost:3000/api
token=your-dev-token-here

Example Output

Express.js Project

Found 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"
}

Best Practices

  1. Use Environment Variables: Never hardcode URLs or tokens
  2. Add Descriptions: Include comments explaining each endpoint
  3. Example Data: Provide realistic example request bodies
  4. Group Logically: Organize by resource or feature
  5. Document Parameters: Add comments for required/optional params
  6. Include Tests: Add assertions or validation comments

Validation Checklist

  • 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

Usage

After generating the files:

  1. Open any .req file in Cursor
  2. Click "Execute Request" CodeLens above the request
  3. View response in .res file
  4. Switch environments using status bar

Supported Frameworks

  • 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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment