|
| 1 | +# API Testing Files |
| 2 | + |
| 3 | +This directory contains HTTP request files for testing all APIs in the BuildWithAspire application. |
| 4 | + |
| 5 | +## Files Overview |
| 6 | + |
| 7 | +- **`apiservice.http`** - Comprehensive tests for the main API service |
| 8 | +- **`mcpserver.http`** - Tests for the MCP (Model Context Protocol) server |
| 9 | +- **`webfrontend.http`** - Tests for the web frontend endpoints |
| 10 | + |
| 11 | +## How to Use |
| 12 | + |
| 13 | +### 1. Using VS Code REST Client Extension |
| 14 | + |
| 15 | +Install the [REST Client](https://marketplace.visualstudio.com/items?itemName=humao.rest-client) extension for VS Code. |
| 16 | + |
| 17 | +1. Open any `.http` file |
| 18 | +2. Click the "Send Request" button above each request |
| 19 | +3. View the response in the new tab |
| 20 | + |
| 21 | +### 2. Update Base URLs |
| 22 | + |
| 23 | +Before testing, update the base URLs in each file to match your current Aspire deployment: |
| 24 | + |
| 25 | +1. Run `aspire run` |
| 26 | +2. Check the Aspire dashboard for current port assignments |
| 27 | +3. Update the `@baseUrl` variables in each file |
| 28 | + |
| 29 | +Example port assignments (these change on each run): |
| 30 | +``` |
| 31 | +webfrontend: https://localhost:7051 |
| 32 | +apiservice: https://localhost:7287 |
| 33 | +mcpserver: http://localhost:34055 |
| 34 | +``` |
| 35 | + |
| 36 | +### 3. Testing Workflows |
| 37 | + |
| 38 | +#### API Service Testing |
| 39 | +Use `apiservice.http` for comprehensive API testing: |
| 40 | +1. Test weather endpoints |
| 41 | +2. Create conversations |
| 42 | +3. Send messages |
| 43 | +4. Test chat functionality |
| 44 | + |
| 45 | +#### MCP Server Testing |
| 46 | +Use `mcpserver.http` to test the weather tools directly. |
| 47 | + |
| 48 | +## API Documentation |
| 49 | + |
| 50 | +### Scalar Documentation (Interactive) |
| 51 | + |
| 52 | +When running in development mode, visit these URLs in your browser: |
| 53 | + |
| 54 | +- **API Service**: `https://localhost:7287/scalar/v1` |
| 55 | +- **MCP Server**: `http://localhost:34055/scalar/v1` |
| 56 | + |
| 57 | +### OpenAPI Specifications |
| 58 | + |
| 59 | +- **API Service**: `https://localhost:7287/openapi/v1.json` |
| 60 | +- **MCP Server**: `http://localhost:34055/openapi/v1.json` |
| 61 | + |
| 62 | +## Common Test Scenarios |
| 63 | + |
| 64 | +### 1. MCP Tool Testing |
| 65 | +```http |
| 66 | +# List available MCP tools |
| 67 | +GET {{apiService}}/mcp/tools |
| 68 | +
|
| 69 | +# Call weather tools via API Service |
| 70 | +POST {{apiService}}/mcp/call/GetCurrentWeather |
| 71 | +POST {{apiService}}/mcp/call/GetWeatherForecast |
| 72 | +
|
| 73 | +# Direct MCP protocol calls to server (JSON-RPC) |
| 74 | +POST {{mcpServer}}/mcp |
| 75 | +{ |
| 76 | + "jsonrpc": "2.0", |
| 77 | + "id": "1", |
| 78 | + "method": "tools/call", |
| 79 | + "params": { |
| 80 | + "name": "GetCurrentWeather", |
| 81 | + "arguments": {} |
| 82 | + } |
| 83 | +} |
| 84 | +``` |
| 85 | + |
| 86 | +### 2. Conversation Flow |
| 87 | +```http |
| 88 | +# 1. Create conversation |
| 89 | +POST {{apiService}}/conversations |
| 90 | +{ |
| 91 | + "name": "Test Chat" |
| 92 | +} |
| 93 | +
|
| 94 | +# 2. Send message (use ID from step 1) |
| 95 | +POST {{apiService}}/conversations/{id}/messages |
| 96 | +{ |
| 97 | + "message": "Hello!" |
| 98 | +} |
| 99 | +
|
| 100 | +# 3. Get conversation history |
| 101 | +GET {{apiService}}/conversations/{id} |
| 102 | +``` |
| 103 | + |
| 104 | +### 3. Health Monitoring |
| 105 | +```http |
| 106 | +GET {{apiService}}/health |
| 107 | +GET {{mcpServer}}/health |
| 108 | +GET {{webFrontend}}/health |
| 109 | +``` |
| 110 | + |
| 111 | +## Troubleshooting |
| 112 | + |
| 113 | +### Port Issues |
| 114 | +If requests fail, check that: |
| 115 | +1. Aspire is running (`aspire run`) |
| 116 | +2. Ports match the Aspire dashboard |
| 117 | +3. Services are healthy (green status) |
| 118 | + |
| 119 | +### SSL/TLS Issues |
| 120 | +For HTTPS endpoints, you may need to: |
| 121 | +1. Accept self-signed certificates in your browser |
| 122 | +2. Use HTTP variants if available |
| 123 | +3. Check Aspire certificate configuration |
| 124 | + |
| 125 | +### Authentication |
| 126 | +Most endpoints don't require authentication in development mode. For production deployments, you may need to add authorization headers. |
| 127 | + |
| 128 | +## Contributing |
| 129 | + |
| 130 | +When adding new endpoints: |
| 131 | +1. Add them to the appropriate service file |
| 132 | +2. Include proper documentation |
| 133 | +3. Add examples with realistic data |
| 134 | +4. Update this README if needed |
0 commit comments