OpenAPI to HTTP
VS Code extension that generates .http files from OpenAPI specifications for easy API testing.
🎯 Features
- ✅ OpenAPI 3.x & Swagger 2.0 support - Parse both JSON and YAML formats
- ✅ Smart data generation - Automatically generates sample data based on schema types and validations
- ✅ Complete coverage - Generates requests for all endpoints with all HTTP methods
- ✅ Type-aware - Respects minLength, maxLength, minimum, maximum, enum, pattern, and more
- ✅ Context menu integration - Right-click to generate directly from your OpenAPI file
- ✅ Format support - Handles date, email, uuid, uri, and other special formats
- ✅ Easy testing - Use with REST Client extension to test your APIs immediately
📦 Installation
From Source
git clone <repository-url>
cd openapi-to-http
npm install
npm run compile
Press F5 to run in Extension Development Host.
From VSIX (future)
- Download the
.vsix file
- In VS Code: Extensions → ⋯ → Install from VSIX
🚀 Usage
- Open an OpenAPI specification file (JSON or YAML format)
- Right-click in the editor
- Select "Generate .http" from the context menu
- Enter the desired filename for the
.http file (e.g., api-tests.http)
- The file will be created in the same directory as your OpenAPI spec
- Use REST Client extension to send requests
📝 Example
openapi: 3.0.0
info:
title: Sample API
version: 1.0.0
servers:
- url: https://api.example.com/v1
paths:
/users:
post:
summary: Create a user
requestBody:
required: true
content:
application/json:
schema:
type: object
required: [username, email]
properties:
username:
type: string
minLength: 3
maxLength: 20
email:
type: string
format: email
age:
type: integer
minimum: 18
Output: Generated .http File
# Generated from OpenAPI Specification
# Title: Sample API
# Version: 1.0.0
@baseUrl = https://api.example.com/v1
###
# Create a user
# Operation ID: createUser
POST {{baseUrl}}/users
Content-Type: application/json
{
"username": "example",
"email": "user@example.com",
"age": 25
}
###
🏗️ Project Structure
openapi-to-http/
├── src/
│ ├── extension.ts # Main extension entry point
│ ├── openapi-parser.ts # OpenAPI file parser and validator
│ ├── http-generator.ts # .http file generator
│ └── data-generator.ts # Sample data generator
├── examples/
│ ├── sample-api.yaml # Pet Store API example
│ └── ecommerce-api.json # E-commerce API example
├── package.json # Extension manifest
├── tsconfig.json # TypeScript configuration
├── USAGE.md # Detailed usage guide (Russian)
├── TESTING.md # Testing guide (Russian)
└── README.md # This file
🛠️ Technologies
🎨 Data Generation Features
The extension intelligently generates sample data based on:
Types
string → generates appropriate text
number/integer → generates valid numbers
boolean → generates true/false
array → generates array with correct item types
object → generates nested objects
date → 2025-11-26
date-time → 2025-11-26T10:30:00.000Z
email → user@example.com
uri/url → https://example.com
uuid → 123e4567-e89b-12d3-a456-426614174000
ipv4 → 192.168.1.1
ipv6 → 2001:0db8:85a3:0000:0000:8a2e:0370:7334
Validations
minLength/maxLength → string length constraints
minimum/maximum → number range constraints
minItems/maxItems → array size constraints
multipleOf → number divisibility
pattern → regex patterns (simplified)
enum → uses first enum value
required → ensures required fields are present
📚 Documentation
🧪 Testing
See TESTING.md for detailed testing instructions.
Quick test:
- Press
F5 to launch Extension Development Host
- Open
examples/sample-api.yaml
- Right-click → Generate .http
- Check the generated file
🔧 Development
# Install dependencies
npm install
# Compile
npm run compile
# Watch mode
npm run watch
# Lint
npm run lint
# Debug
Press F5 in VS Code
📋 Requirements
🚧 Known Limitations
- Component references (
$ref) are handled in a simplified manner
- Authentication schemas are not yet included in generated requests
- Some complex JSON Schema constructs may generate simplified examples
🔮 Future Enhancements
- [ ] Full
$ref resolution with component support
- [ ] Authentication header generation (Bearer, API Key, OAuth)
- [ ] Configuration options for data generation
- [ ] Environment variables support
- [ ] Test assertions and expected responses
- [ ] Batch file generation (one file per tag/path)
- [ ] Custom templates support
📄 License
MIT
🤝 Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
👤 Author
Created with ❤️ for the VS Code community