{"_id":"@boolesai/tspec-plugin-http","_rev":"2-e9f3a6dbc04ba7122b04e3b8c3554b87","name":"@boolesai/tspec-plugin-http","dist-tags":{"latest":"1.0.1"},"versions":{"1.0.0":{"name":"@boolesai/tspec-plugin-http","version":"1.0.0","keywords":["tspec","tspec-plugin","http","https","api-testing","rest"],"author":{"name":"TSpec Team"},"license":"MIT","_id":"@boolesai/tspec-plugin-http@1.0.0","maintainers":[{"name":"booles.ai","email":"ai.booles@gmail.com"}],"homepage":"https://github.com/boolesai/testing-spec#readme","bugs":{"url":"https://github.com/boolesai/testing-spec/issues"},"dist":{"shasum":"b0c941b76e75e7cad4a7f8647ac3022b6f754342","tarball":"https://registry.npmjs.org/@boolesai/tspec-plugin-http/-/tspec-plugin-http-1.0.0.tgz","fileCount":15,"integrity":"sha512-DucFtxb39tdPMzvId05mOsU8WWpx1UQ/XvosywLDaSMFpKUJoeXuVofcvEATI6fNcXn6qystZv3DYKFYyLwcJw==","signatures":[{"sig":"MEUCIHsbHz3V0wAM3nAN+IwJy/gyhC4R4uC/QmejxByJ3amUAiEAgpQYXQC32430Q42O1KRrB5GNinkIQpAwyKKDft6FjzA=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":34085},"main":"./dist/index.js","type":"module","tspec":{"plugin":true},"types":"./dist/index.d.ts","engines":{"node":">=18.0.0"},"exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.js"}},"gitHead":"9e4e82ce969b525abc2da91acc57f0cd7cc66781","scripts":{"dev":"vite build --watch","test":"vitest run","build":"vite build && tsc --emitDeclarationOnly --outDir dist","test:watch":"vitest","prepublishOnly":"npm run build"},"_npmUser":{"name":"booles.ai","email":"ai.booles@gmail.com"},"repository":{"url":"git+https://github.com/boolesai/testing-spec.git","type":"git","directory":"plugins/tspec-protocol-http"},"_npmVersion":"10.7.0","description":"HTTP/HTTPS protocol plugin for TSpec","directories":{},"_nodeVersion":"20.14.0","dependencies":{"axios":"^1.7.0"},"_hasShrinkwrap":false,"devDependencies":{"vite":"^7.0.0","vitest":"^2.1.9","typescript":"^5.0.0","@types/node":"^22.0.0","@boolesai/tspec":"^1.2.0"},"peerDependencies":{"@boolesai/tspec":"^1.2.0"},"_npmOperationalInternal":{"tmp":"tmp/tspec-plugin-http_1.0.0_1770131280876_0.6695283329145749","host":"s3://npm-registry-packages-npm-production"}},"1.0.1":{"name":"@boolesai/tspec-plugin-http","version":"1.0.1","description":"HTTP/HTTPS protocol plugin for TSpec","type":"module","main":"./dist/index.js","types":"./dist/index.d.ts","exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.js"}},"scripts":{"build":"vite build && tsc --emitDeclarationOnly --outDir dist","dev":"vite build --watch","test":"vitest run","test:watch":"vitest","prepublishOnly":"npm run build"},"keywords":["tspec","tspec-plugin","http","https","api-testing","rest"],"tspec":{"plugin":true},"peerDependencies":{"@boolesai/tspec":"^1.3.2"},"dependencies":{"axios":"^1.7.0"},"devDependencies":{"@boolesai/tspec":"^1.3.2","@types/node":"^22.0.0","typescript":"^5.0.0","vite":"^7.0.0","vitest":"^2.1.9"},"author":{"name":"TSpec Team"},"license":"MIT","repository":{"type":"git","url":"git+https://github.com/boolesai/testing-spec.git","directory":"plugins/tspec-protocol-http"},"engines":{"node":">=18.0.0"},"_id":"@boolesai/tspec-plugin-http@1.0.1","gitHead":"e1a4c56ecc43cf45001b3c8cb1dddd0abcace3b3","bugs":{"url":"https://github.com/boolesai/testing-spec/issues"},"homepage":"https://github.com/boolesai/testing-spec#readme","_nodeVersion":"20.14.0","_npmVersion":"10.7.0","dist":{"integrity":"sha512-xYPnEn2hBVazcLWRFnr0WtTZuiK+UZVM3S/yzMUwEJfYa3db5nzz2Ewc8ifZrAM++8RYfp4CwFpqRciQQ5iCFA==","shasum":"43f6a6a2bdc92589cdf4cfe474fb5ef08b9b007a","tarball":"https://registry.npmjs.org/@boolesai/tspec-plugin-http/-/tspec-plugin-http-1.0.1.tgz","fileCount":16,"unpackedSize":41946,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEQCIBrG1g9aJVvNbQvO93WshbBcB1RIXlZhJH7E93tRtsLDAiAwFqAumc2ngTWTcp1JzXBTyH7sHj1/9bXvV7u5oFmyDg=="}]},"_npmUser":{"name":"booles.ai","email":"ai.booles@gmail.com"},"directories":{},"maintainers":[{"name":"booles.ai","email":"ai.booles@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/tspec-plugin-http_1.0.1_1772197672427_0.44927208983789324"},"_hasShrinkwrap":false}},"time":{"created":"2026-02-03T15:08:00.752Z","modified":"2026-02-27T13:07:52.716Z","1.0.0":"2026-02-03T15:08:01.003Z","1.0.1":"2026-02-27T13:07:52.585Z"},"bugs":{"url":"https://github.com/boolesai/testing-spec/issues"},"author":{"name":"TSpec Team"},"license":"MIT","homepage":"https://github.com/boolesai/testing-spec#readme","keywords":["tspec","tspec-plugin","http","https","api-testing","rest"],"repository":{"type":"git","url":"git+https://github.com/boolesai/testing-spec.git","directory":"plugins/tspec-protocol-http"},"description":"HTTP/HTTPS protocol plugin for TSpec","maintainers":[{"name":"booles.ai","email":"ai.booles@gmail.com"}],"readme":"# TSpec HTTP Protocol Plugin\n\nHTTP/HTTPS protocol plugin for [TSpec](https://github.com/boolesai/testing-spec) - enables REST API testing and HTTP endpoint validation.\n\n## Features\n\n- ✅ **Full HTTP/HTTPS Support**: GET, POST, PUT, DELETE, PATCH, HEAD, OPTIONS\n- 🔒 **Authentication**: Bearer tokens, API keys, custom headers\n- 📦 **Multiple Body Formats**: JSON, form data, text, binary\n- 🔄 **Request/Response Handling**: Query parameters, headers, cookies\n- ⚡ **Configurable Options**: Timeouts, redirects, retry logic\n- 🎯 **JSONPath Assertions**: Validate response structure and values\n- 🌐 **Base URL Configuration**: Centralized endpoint management\n\n## Installation\n\n### Using TSpec CLI (Recommended)\n\n```bash\ntspec plugin:install @boolesai/tspec-plugin-http\n```\n\n### Manual Installation\n\n```bash\nnpm install --save-dev @boolesai/tspec-plugin-http\n```\n\nThen add to your `tspec.config.json`:\n\n```json\n{\n  \"plugins\": [\"@boolesai/tspec-plugin-http\"]\n}\n```\n\n## Usage\n\n### Basic Example\n\nCreate a test case file `login.http.tcase`:\n\n```yaml\nversion: \"1.0\"\ndescription: \"Test user login API\"\n\nhttp:\n  method: \"POST\"\n  path: \"/api/v1/auth/login\"\n  headers:\n    Content-Type: \"application/json\"\n  body:\n    username: \"test_user\"\n    password: \"password123\"\n\nassertions:\n  - type: \"json_path\"\n    expression: \"$.success\"\n    operator: \"equals\"\n    expected: true\n  - type: \"json_path\"\n    expression: \"$.token\"\n    operator: \"exists\"\n```\n\nRun the test:\n\n```bash\ntspec run login.http.tcase\n```\n\n### Common Use Cases\n\n#### GET Request with Query Parameters\n\n```yaml\nhttp:\n  method: \"GET\"\n  path: \"/api/users\"\n  query:\n    page: \"1\"\n    limit: \"10\"\n    sort: \"name\"\n\nassertions:\n  - type: \"json_path\"\n    expression: \"$.data.length\"\n    operator: \"equals\"\n    expected: 10\n```\n\n#### Authenticated Request\n\n```yaml\nhttp:\n  method: \"GET\"\n  path: \"/api/profile\"\n  headers:\n    Authorization: \"Bearer ${ACCESS_TOKEN}\"\n\nassertions:\n  - type: \"json_path\"\n    expression: \"$.status\"\n    operator: \"equals\"\n    expected: 200\n```\n\n#### POST with JSON Body\n\n```yaml\nhttp:\n  method: \"POST\"\n  path: \"/api/users\"\n  headers:\n    Content-Type: \"application/json\"\n  body:\n    name: \"John Doe\"\n    email: \"john@example.com\"\n    role: \"admin\"\n\nassertions:\n  - type: \"json_path\"\n    expression: \"$.id\"\n    operator: \"exists\"\n```\n\n#### File Upload\n\n```yaml\nhttp:\n  method: \"POST\"\n  path: \"/api/upload\"\n  headers:\n    Content-Type: \"multipart/form-data\"\n  body:\n    file: \"@/path/to/file.pdf\"\n    description: \"Document upload\"\n```\n\n## Configuration\n\nConfigure plugin behavior in `tspec.config.json`:\n\n```json\n{\n  \"plugins\": [\"@boolesai/tspec-plugin-http\"],\n  \"pluginOptions\": {\n    \"@boolesai/tspec-plugin-http\": {\n      \"baseURL\": \"https://api.example.com\",\n      \"timeout\": 30000,\n      \"followRedirects\": true,\n      \"maxRedirects\": 5,\n      \"validateStatus\": null,\n      \"headers\": {\n        \"User-Agent\": \"TSpec/1.0\",\n        \"Accept\": \"application/json\"\n      }\n    }\n  }\n}\n```\n\n### Configuration Options\n\n| Option | Type | Default | Description |\n|--------|------|---------|-------------|\n| `baseURL` | `string` | - | Base URL prepended to all paths |\n| `timeout` | `number` | `30000` | Request timeout in milliseconds |\n| `followRedirects` | `boolean` | `true` | Follow HTTP redirects |\n| `maxRedirects` | `number` | `5` | Maximum redirect count |\n| `validateStatus` | `function` | - | Custom status validation function |\n| `headers` | `object` | `{}` | Default headers for all requests |\n| `maxContentLength` | `number` | - | Maximum response body size |\n| `maxBodyLength` | `number` | - | Maximum request body size |\n\n## Request Schema\n\nThe HTTP request block supports the following fields:\n\n```yaml\nhttp:\n  method: string          # Required: GET, POST, PUT, DELETE, PATCH, HEAD, OPTIONS\n  path: string           # Required: Request path or full URL\n  headers: object        # Optional: Request headers\n  query: object          # Optional: Query string parameters\n  body: object | string  # Optional: Request body (JSON, text, or form data)\n  timeout: number        # Optional: Override default timeout\n```\n\n## Response Structure\n\nThe plugin returns responses in the following format:\n\n```typescript\n{\n  protocol: 'http' | 'https',\n  statusCode: number,\n  headers: Record<string, string>,\n  body: any,\n  duration: number,\n  url: string,\n  method: string\n}\n```\n\n## Environment Variables\n\nUse environment variables in test cases:\n\n```yaml\nhttp:\n  method: \"POST\"\n  path: \"/api/login\"\n  body:\n    username: \"${TEST_USERNAME}\"\n    password: \"${TEST_PASSWORD}\"\n```\n\nSet via command line:\n\n```bash\ntspec run --env TEST_USERNAME=admin --env TEST_PASSWORD=secret login.http.tcase\n```\n\nOr in a `.env` file:\n\n```env\nTEST_USERNAME=admin\nTEST_PASSWORD=secret\nAPI_BASE_URL=https://api.example.com\n```\n\n## Advanced Features\n\n### Template Inheritance\n\nReuse common configurations:\n\n```yaml\n# base-api.http.tcase\nversion: \"1.0\"\ndescription: \"Base API configuration\"\ntemplate: true\n\nhttp:\n  headers:\n    Authorization: \"Bearer ${API_TOKEN}\"\n    Content-Type: \"application/json\"\n```\n\n```yaml\n# create-user.http.tcase\nversion: \"1.0\"\ndescription: \"Create new user\"\nextends: \"base-api.http.tcase\"\n\nhttp:\n  method: \"POST\"\n  path: \"/api/users\"\n  body:\n    name: \"Jane Doe\"\n```\n\n### Data-Driven Testing\n\nRun the same test with multiple data sets:\n\n```yaml\nversion: \"1.0\"\ndescription: \"Test multiple user logins\"\n\ndata:\n  - username: \"admin\"\n    password: \"admin123\"\n  - username: \"user\"\n    password: \"user123\"\n\nhttp:\n  method: \"POST\"\n  path: \"/api/login\"\n  body:\n    username: \"${username}\"\n    password: \"${password}\"\n\nassertions:\n  - type: \"json_path\"\n    expression: \"$.success\"\n    operator: \"equals\"\n    expected: true\n```\n\n### Chaining Requests\n\nUse outputs from one request in another:\n\n```yaml\n# First test case - login and save token\nversion: \"1.0\"\ndescription: \"Login and extract token\"\n\nhttp:\n  method: \"POST\"\n  path: \"/api/login\"\n  body:\n    username: \"admin\"\n    password: \"admin123\"\n\noutputs:\n  auth_token:\n    json_path: \"$.token\"\n```\n\n```yaml\n# Second test case - use saved token\nversion: \"1.0\"\ndescription: \"Get user profile\"\n\nhttp:\n  method: \"GET\"\n  path: \"/api/profile\"\n  headers:\n    Authorization: \"Bearer ${auth_token}\"\n```\n\n## Examples\n\nSee the [demo](../../demo/test) directory for more examples:\n\n- [create_book.http.tcase](../../demo/test/create_book.http.tcase)\n- [get_book.http.tcase](../../demo/test/get_book.http.tcase)\n- [list_books.http.tcase](../../demo/test/list_books.http.tcase)\n\n## Troubleshooting\n\n### Connection Errors\n\n```bash\n# Check if the API is accessible\ncurl -v https://api.example.com/health\n\n# Test with increased timeout\ntspec run --plugin-options='{\"@boolesai/tspec-plugin-http\":{\"timeout\":60000}}' test.http.tcase\n```\n\n### SSL/TLS Issues\n\n```json\n{\n  \"pluginOptions\": {\n    \"@boolesai/tspec-plugin-http\": {\n      \"rejectUnauthorized\": false\n    }\n  }\n}\n```\n\n### Debug Mode\n\nEnable detailed logging:\n\n```bash\nDEBUG=tspec:* tspec run test.http.tcase\n```\n\n## API Reference\n\n### HttpRunner\n\n```typescript\nimport { HttpRunner } from '@boolesai/tspec-plugin-http';\n\nconst runner = new HttpRunner({\n  baseURL: 'https://api.example.com',\n  timeout: 30000\n});\n\nconst response = await runner.execute(testCase);\n```\n\n### Request Builder\n\n```typescript\nimport { buildAxiosConfig, buildUrl } from '@boolesai/tspec-plugin-http';\n\nconst config = buildAxiosConfig(request, options);\nconst url = buildUrl(baseURL, path, query);\n```\n\n## Contributing\n\nContributions are welcome! Please see the [Plugin Development Guide](../DEVELOPMENT.md) for details.\n\n## License\n\nMIT License - see [LICENSE](../../LICENSE) for details.\n\n## Related\n\n- [TSpec Core](../../core/README.md)\n- [TSpec CLI](../../cli/README.md)\n- [Plugin Development Guide](../DEVELOPMENT.md)\n- [Web Plugin](../tspec-protocol-web/README.md)\n- [Full Documentation](https://tspec.boolesai.com)\n","readmeFilename":"README.md"}