0.0.3 • Published 6 months ago

2wasm v0.0.3

Weekly downloads
-
License
MIT
Repository
github
Last release
6 months ago

OpenAPI to WebAssembly CLI

A command-line tool built with Bun and Extism to convert OpenAPI specifications into WebAssembly plugins.

Features

  • Convert OpenAPI specification files (YAML or JSON) to WASM plugins
  • Automatically generate TypeScript handlers for each API endpoint
  • Create a compatible WebAssembly module and manifest file
  • Support for path parameters, query parameters, and request bodies

Prerequisites

Installation

NPM Installation

# Install globally
npm install -g openapi2wasm

# Or install locally in your project
npm install --save-dev openapi2wasm

Manual Installation

# Clone the repository
git clone https://github.com/yourusername/openapi-2-wasm-cli.git
cd openapi-2-wasm-cli

# Install dependencies
bun install

Usage

# If installed via npm (globally)
openapi2wasm --schema path/to/your/openapi.yaml

# If installed manually or locally
./index.ts --schema path/to/your/openapi.yaml

# Specify output directory
openapi2wasm --schema path/to/your/openapi.yaml --output ./dist

# Specify a custom name for the plugin
openapi2wasm --schema path/to/your/openapi.yaml --name my-custom-plugin

Options

  • --schema, -s: Path to the OpenAPI schema file (YAML or JSON) (required)
  • --output, -o: Output directory for the generated files (default: current directory)
  • --name, -n: Custom name for the plugin (default: derived from the schema's title)

Output Files

The tool generates:

  • [plugin-name].wasm: The WebAssembly plugin file
  • manifest.json: The plugin manifest file for Extism

How it Works

  1. The tool reads and parses the OpenAPI specification
  2. Generates TypeScript code for each API endpoint
  3. Creates PDK integration files
  4. Compiles the TypeScript code to JavaScript
  5. Uses Extism to build the final WASM plugin

License

MIT