0.0.3 • Published 6 months ago
2wasm v0.0.3
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
- Bun (v1.0.0 or higher)
- Extism JS PDK
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 filemanifest.json
: The plugin manifest file for Extism
How it Works
- The tool reads and parses the OpenAPI specification
- Generates TypeScript code for each API endpoint
- Creates PDK integration files
- Compiles the TypeScript code to JavaScript
- Uses Extism to build the final WASM plugin
License
MIT
0.0.3
6 months ago