npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@syntropiq/openapi-codegen

v1.0.0

Published

A tool to generate TypeScript stubs and types from OpenAPI YAML files with configurable endpoint URLs and API keys.

Readme

OpenAPI Stub Generator

A TypeScript tool that generates Cloudflare Workers-compatible API stubs and types from OpenAPI YAML specifications.

Features

  • 🚀 Cloudflare Workers Native: Generates code specifically optimized for Cloudflare Workers
  • 📝 Complete Type Generation: Converts OpenAPI schemas to comprehensive TypeScript interfaces
  • 🔄 Modular Architecture: Creates separate workers for each route group
  • Zero Dependencies: Generated code runs without external runtime dependencies
  • 🛠️ Configurable: Support for custom API endpoints and authentication
  • 🎯 AI-Ready: Optional AI enhancement for business logic (when API key provided)

Installation

npm install
npm run build

Usage

Basic Usage

  1. Place your OpenAPI YAML file in the examples/ directory
  2. Configure your settings in src/config/index.ts
  3. Run the generator:
npm run generate

Advanced Configuration

Edit src/config/index.ts:

export const config = {
  outputDir: './generated',
  apiKey: process.env.OPENAI_API_KEY, // Optional: for AI enhancement
  apiUrl: 'https://api.openai.com/v1', // Optional: custom AI endpoint
  generateCloudflareWorkers: true,
  enableTypeGeneration: true,
};

Generated Output

The tool generates:

  • types.ts: Complete TypeScript type definitions
  • api-client.ts: Cloudflare Workers-compatible API client
  • worker.ts: Main router that delegates to route-specific workers
  • *_worker.ts: Individual workers for each route group (audio, chat, etc.)

Generated Code Structure

generated/
├── types.ts              # TypeScript interfaces
├── api-client.ts          # API client with fetch methods
├── worker.ts              # Main router worker
├── audio_worker.ts        # Audio-related endpoints
├── chat_worker.ts         # Chat completions
├── assistants_worker.ts   # AI assistants
└── ...                    # Additional route workers

Deployment

Cloudflare Workers

  1. Copy generated files to your Workers project
  2. Set environment variables:
    API_KEY=your_api_key
    API_BASE_URL=https://api.openai.com/v1
  3. Deploy using Wrangler:
    wrangler deploy

Example Worker Usage

// Import the main worker
import worker from './generated/worker';

export default worker;

Installation

  1. Clone the repository:

    git clone <repository-url>
  2. Navigate to the project directory:

    cd openapi-stub-generator
  3. Install the dependencies:

    npm install

Usage

  1. Configure the API endpoint and key in src/config/index.ts.

  2. Place your OpenAPI YAML file in the examples directory.

  3. Run the generator:

    npm run generate
  4. Check the dist directory for the generated stubs and types.

Example

Refer to examples/basic-usage.ts for a demonstration of how to use the stub generator tool with a sample OpenAPI YAML file.

Contributing

Contributions are welcome! Please open an issue or submit a pull request for any enhancements or bug fixes.

License

This project is licensed under the MIT License. See the LICENSE file for details.