JSPM

http-generator

0.1.0
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 1
  • Score
    100M100P100Q30104F
  • License MIT

Generate .http files from OpenAPI specifications

Package Exports

  • http-generator
  • http-generator/dist/index.js

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (http-generator) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

http-generator

Generate .http files from OpenAPI specifications

Features

  • 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

Installation

Install in your project folder:

npm i http-generator -D
# Using yarn
yarn add http-generator --dev
# Using pnpm
pnpm add http-generator -D

Usage

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

Configuration File

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 your package.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",
});

Contributing

Contributions are welcome! Please submit issues or pull requests.

License

Licensed under the MIT License. See the LICENSE file for details.