δΈζζζ‘£ | English
An intelligent Visual Studio Code extension that automatically detects and tests C# Web API endpoints directly from your code editor with AI-powered smart JSON generation.
- Intelligently recognizes C# Web API controllers and methods
- Parses HTTP method attributes (
[HttpGet],[HttpPost], etc.) - Extracts route templates from
[Route]attributes - Analyzes method signatures and parameter sources
- Execute API calls directly from your code editor
- CodeLens integration with inline "Test API" buttons
- Interactive testing panel with Apifox-style UI
- Multiple endpoints can be tested simultaneously
- Path Parameters:
{id}in routes - Query Parameters:
[FromQuery]attributes - Request Body:
[FromBody]attributes with full C# class parsing - Headers:
[FromHeader]attributes - Form Data:
[FromForm]attributes with file upload support
- Generates realistic test data based on C# class definitions
- Understands property names, types, and C# XML comments
- Reads C# class attributes for additional context
- Supports OpenAI, Azure OpenAI, and custom AI providers
- Preserves conversation history per API panel with "View AI" feature
- One-click restore to original template
- Multiple environment support (Development, Staging, Production, etc.)
- Each environment with custom base URL, base path, and headers
- Quick switching via status bar
- Per-environment header configuration
- Workspace-level settings persistence
- Body Editor: Full-featured JSON editor with syntax highlighting, formatting, and AI generation
- Form Data Support: Multipart form data with file upload and text fields
- Value Editor: Expandable modal editor for long header/query parameter values
- Response Viewer: Formatted JSON response with syntax highlighting and collapsible structure
- Request History: View AI conversation history and restore original JSON templates
- Smart Tab Selection: Automatically opens the most relevant tab (Form/Body/Query/Headers)
- Performance Optimization: Configurable search strategy (fast/balanced/thorough) for class definition lookup
- Parameter Persistence: Automatically saves and restores test parameters per environment (URL, headers, query params, body, form data)
- Cache Management: Clear cached parameters and class definitions to force fresh API detection
- Open VS Code
- Press
Ctrl+Shift+X(Windows/Linux) orCmd+Shift+X(Mac) - Search for "C# API Tester"
- Click Install
- Download the
.vsixfile - Open VS Code
- Press
Ctrl+Shift+Pβ "Extensions: Install from VSIX..." - Select the downloaded file
Open a C# controller file:
[ApiController]
[Route("api/[controller]")]
public class UsersController : ControllerBase
{
[HttpGet("{id}")]
public async Task<ActionResult<User>> GetUser(int id)
{
// Your code here
}
[HttpPost]
public async Task<ActionResult<User>> CreateUser([FromBody] CreateUserDto userDto)
{
// Your code here
}
}You'll see "π Test API" buttons above each method. Click to test!
First time using? Set up your environment:
- Click the environment indicator in the status bar
- Choose "Add New Environment"
- Configure:
- Name: "Development"
- Base URL: "http://localhost:5000"
- Base Path: "/api" (optional)
- Headers:
{"Authorization": "Bearer token"}
Enable AI-powered JSON generation:
- Open Settings:
Ctrl+,β Search "C# API Tester" - Configure AI settings:
{ "csharpApiTester.ai.enabled": true, "csharpApiTester.ai.provider": "openai", "csharpApiTester.ai.apiKey": "sk-...", "csharpApiTester.ai.model": "gpt-3.5-turbo" }
Support for [FromForm] parameters:
[HttpPost("upload")]
public async Task<IActionResult> UploadFile(
[FromForm] IFormFile file,
[FromForm] string title,
[FromForm] string description)
{
// Handle file upload
}The extension automatically:
- Creates a Form tab in the test panel
- Detects file fields (
IFormFile,Stream,byte[]) - Supports text fields and file inputs
- Sends
multipart/form-datarequests
When testing endpoints with complex request bodies:
- Click "π€ AI Generate" button in the Body tab
- AI analyzes your C# class definition including:
- Property names and types
- XML documentation comments (
/// <summary>) - Data annotation attributes
- Nested class structures
public class CreateUserDto { /// <summary> /// User's full name /// </summary> [Required] [MaxLength(100)] public string Name { get; set; } /// <summary> /// Email address /// </summary> [EmailAddress] public string Email { get; set; } public int Age { get; set; } public AddressDto Address { get; set; } }
- AI generates realistic test data respecting all constraints
- View the AI conversation and prompt with "π¬ View AI" button
- Restore original JSON template with "βΊ Restore" button
- All conversation history is preserved per API panel
The test panel intelligently selects the default tab:
- Form Tab β If
[FromForm]parameters exist - Body Tab β If
[FromBody]parameters exist - Query Tab β If
[FromQuery]parameters exist - Headers Tab β Fallback
The extension automatically saves your test parameters for each API endpoint per environment:
- Auto-save: Parameters are saved when you modify URL, headers, query params, body, or form data
- Auto-restore: Previously saved parameters are restored when you reopen the test panel
- Environment-aware: Each environment maintains separate parameter sets for the same endpoint
- Cached Data: Includes URL, HTTP method, headers, query parameters, request body, and form data
To start fresh with default values, use the "Clear Cache And Test" command from CodeLens or command palette.
| Setting | Description | Default |
|---|---|---|
csharpApiTester.timeout |
Request timeout (ms) | 30000 |
csharpApiTester.enableApiDetection |
Enable automatic API detection and CodeLens | true |
csharpApiTester.searchStrategy |
Class definition search strategy | "balanced" |
csharpApiTester.searchFileLimit |
Max files to search (custom strategy only) | 2000 |
csharpApiTester.ai.enabled |
Enable AI features | false |
csharpApiTester.ai.provider |
AI provider (openai/azure-openai/custom) | "openai" |
csharpApiTester.ai.apiKey |
AI API key | "" |
csharpApiTester.ai.endpoint |
AI API endpoint URL | OpenAI default |
csharpApiTester.ai.model |
AI model name | "gpt-3.5-turbo" |
csharpApiTester.ai.maxTokens |
Max tokens per request | 1000 |
csharpApiTester.ai.timeout |
AI request timeout (ms) | 60000 |
csharpApiTester.ai.systemPrompt |
System prompt for AI | Default prompt |
Choose a search strategy based on your project size:
- fast: Searches up to 500 .cs files (best for small projects)
- balanced: Searches up to 1000 .cs files (recommended for most projects)
- thorough: Searches up to 2000 .cs files (for large monorepos)
- custom: Use
searchFileLimitsetting to specify exact limit
{
"csharpApiTester.ai.provider": "openai",
"csharpApiTester.ai.apiKey": "sk-...",
"csharpApiTester.ai.endpoint": "https://api.openai.com/v1/chat/completions",
"csharpApiTester.ai.model": "gpt-3.5-turbo"
}{
"csharpApiTester.ai.provider": "azure-openai",
"csharpApiTester.ai.apiKey": "your-azure-key",
"csharpApiTester.ai.endpoint": "https://your-resource.openai.azure.com/openai/deployments/your-deployment/chat/completions?api-version=2024-02-15-preview",
"csharpApiTester.ai.model": "gpt-35-turbo"
}{
"csharpApiTester.ai.provider": "custom",
"csharpApiTester.ai.apiKey": "your-key",
"csharpApiTester.ai.endpoint": "https://your-api.com/v1/chat/completions"
}Switch between environments quickly:
// .vscode/settings.json
{
"csharpApiTester.environments": [
{
"name": "Development",
"baseUrl": "http://localhost:5000",
"basePath": "/api",
"headers": {
"Authorization": "Bearer dev-token"
}
},
{
"name": "Staging",
"baseUrl": "https://staging-api.example.com",
"basePath": "",
"headers": {
"Authorization": "Bearer staging-token"
}
}
]
}For long header values or query parameters:
- Click the β€’ icon next to the input field
- Edit in a large textarea
- Save changes back to the field
| Command | Description |
|---|---|
C#HttpRequest: Test API Endpoint |
Open test panel for selected endpoint |
C#HttpRequest: Clear Cache And Test |
Clear cached parameters and class definitions, then test endpoint with fresh data |
C#HttpRequest: Manage API Environments |
Open environment management dialog |
C#HttpRequest: Switch Environment |
Quick switch between environments |
C#HttpRequest: Configure API Base URL |
Set base URL for current environment |
C#HttpRequest: Toggle API Detection |
Enable/disable automatic API detection |
C#HttpRequest: Test Debug |
Verify extension activation |
C#HttpRequest: Debug API Detection |
View detected endpoints in console |
This extension is perfect for:
- Backend Developers: Test APIs directly from controller code
- API Development: Rapid prototyping and testing during development
- Documentation: Generate sample requests for API documentation
- Testing: Quick manual testing without leaving your editor
- Learning: Understand API behavior through interactive testing
- CodeLens buttons appear automatically above API methods
- Use
C#HttpRequest: Toggle API Detectionto enable/disable - Refresh the document if CodeLens doesn't appear immediately
- Add XML documentation comments for better AI understanding
- Use descriptive property names (e.g.,
userEmailinstead ofe1) - Include data annotation attributes for realistic data generation
- Review and edit AI-generated values before sending requests
- For large projects, use "fast" search strategy to improve performance
- For better accuracy with complex DTOs, use "thorough" strategy
- Custom strategy allows fine-tuning based on your specific needs
- The extension automatically saves your test parameters (headers, body, query params, etc.)
- Parameters are saved separately for each environment
- To reset to default values, use "Clear Cache And Test" command from CodeLens button or command palette
- Cache clearing also refreshes class definitions for accurate request generation
- Ensure the file is a C# controller with
[ApiController]or[Route]attributes - Check that API detection is enabled in settings
- Try reloading the VS Code window (
Developer: Reload Window)
- Verify AI is enabled:
csharpApiTester.ai.enabled - Check API key is correctly configured
- Test configuration with a simple endpoint first
- Check console output for detailed error messages
- Click the environment indicator in status bar
- Select desired environment from the list
- Verify environment settings in workspace settings
Contributions are welcome! Please follow these steps:
- Fork the repository
- Create a feature branch:
git checkout -b feature/amazing-feature - Commit your changes:
git commit -m 'Add amazing feature' - Push to the branch:
git push origin feature/amazing-feature - Open a Pull Request
Found a bug? Please open an issue with:
- VS Code version
- Extension version
- Steps to reproduce
- Expected vs actual behavior
MIT License - see LICENSE file for details.
- Built with VS Code Extension API
- HTTP client powered by Axios
- UI inspired by Apifox
- AI integration with OpenAI and compatible providers
Enjoy testing your C# APIs! π
If you find this extension helpful, please consider:
- β Starring the GitHub repository
- π Leaving a review on the VS Code Marketplace
- π Reporting issues or suggesting features