A CLI tool that generates Effect Platform HTTP libraries from OpenAPI specification documents.
effect-gen is a code generation tool that transforms OpenAPI specification files into Effect Platform HttpApi implementations. It uses @effect/platform's OpenApiJsonSchema utilities or custom Effect Schema parsers to process OpenAPI specs, then leverages ts-poet for TypeScript code generation and @effect/cli for the command-line interface.
- Parse OpenAPI 3.x specifications using Effect's
OpenApiJsonSchemaor custom Effect Schema - Generate Effect Platform
HttpApiimplementations - Transform OpenAPI schemas into Effect Schema definitions
- Type-safe request/response handling with full Effect integration
- Roundtrip validation: generate OpenAPI spec from HttpApi and compare with original
- Support for authentication middleware and error handling patterns
bun install effect-geneffect-gen generate --input openapi.yaml --output ./generated- Runtime: Bun v1.2.19
- CLI Framework: @effect/cli
- Code Generation: ts-poet
- HTTP Library: @effect/platform
- Schema Validation: @effect/schema
- Language: TypeScript
- Parse OpenAPI Spec: Use
OpenApiJsonSchemafrom@effect/platformor custom Effect Schema to parse the OpenAPI JSON schema - Transform to HttpApi: Convert the parsed OpenAPI structure into Effect Platform
HttpApidefinitions - Generate TypeScript Code: Use ts-poet to generate the HttpApi implementation code
- Validate Roundtrip: Generate an OpenAPI spec from the created HttpApi and compare against the original
- Output Library: Write the generated Effect Platform HTTP implementation to disk
The tool generates:
- Effect Schema definitions for all request/response types
- HttpApi implementation using Effect Platform patterns
- HttpApiGroup and HttpApiEndpoint configurations
- Proper error types and handling
- Middleware integration for authentication and validation
# Install dependencies
bun install
# Run tests
bun test
# Build
bun buildMIT