Generate .http
files from OpenAPI specifications
-
Generate HTTP file(s) either as
- A single file containing all requests
- A file per request
-
Supports OpenAPI v2 and v3
- JSON and YAML formats
- Schema Validation
-
Include authorization headers
-
Include summaries and descriptions
-
Variables for route parameters
-
Specify base-url for convenient environment switching
Install in your project folder:
npm i http-generator -D
# Using yarn
yarn add http-generator --dev
# Using pnpm
pnpm add http-generator -D
Run http-generator with the appropriate options:
Usage: http-generator [options]
Generate .http files from OpenAPI specifications
Options:
-i, --input <input> OpenAPI specifications file or URL
-o, --output <output> Output directory or HTTP file
-b, --base-url <baseUrl> Base URL of the API
-t, --token <token> Authorization token
-s, --skip-validation Skip validation of OpenAPI Specification (default: false)
-v, --version Display version number
-h, --help Display this message
You can also use http-generator
using file configurations or in a property inside your package.json, and you can even use TypeScript and have type-safety while you are using it.
You can use any of these files:
httpgen.config.ts
httpgen.config.js
httpgen.config.cjs
httpgen
property in yourpackage.json
Basic Configuration:
import { defineConfig } from "http-generator";
export default defineConfig({
input: "schema.json",
output: "output.http",
baseUrl: "https://example.com",
skipValidation: false,
token: "Bearer Token",
});
Contributions are welcome! Please submit issues or pull requests.
Licensed under the MIT License. See the LICENSE file for details.