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

@f3liz/rescript-autogen-openapi

v0.7.0

Published

Generate ReScript code with Sury schemas from OpenAPI 3.1 specs. Supports multiple forks with diff/merge capabilities.

Readme

@f3liz/rescript-autogen-openapi

Generate ReScript code with Sury schemas from OpenAPI 3.1 specs. Supports multiple forks with intelligent diff/merge capabilities.

🎯 Features

  • Type-Safe ReScript Code: Generates ReScript types for all request/response schemas.
  • Runtime Validation: Generates Sury validation schemas for runtime safety and parsing.
  • Multi-Fork Support: Intelligently handles multiple API forks (like Misskey, Cherrypick, Firefish) by extracting shared code and generating fork-specific extensions.
  • Unified IR Pipeline: Advanced type inference with a unified intermediate representation that generates both types and schemas.
  • Diff & Merge: Compare specs, generate diff reports, and optimize code reuse across variants.
  • TypeScript Support: First-class TypeScript support via genType. Exported functions and types are idiomatic and fully typed for use in TypeScript projects.

📦 Installation

npm install @f3liz/rescript-autogen-openapi sury

Important: This library has a peer dependency on sury (ReScript Schema). You must install it in your project because the generated code directly depends on it for runtime validation.

Configure rescript.json

Add sury to your project dependencies:

{
  "name": "my-project",
  "dependencies": ["sury"]
}

Ensure you have rescript (^12.0.0) installed.

🚀 Usage

Library API

import { generate } from '@f3liz/rescript-autogen-openapi';

const config = {
  specPath: 'https://misskey.io/api.json',
  outputDir: './src/generated',
  strategy: 'SharedBase', // 'SharedBase' or 'Separate'
  modulePerTag: true,
  targets: {
    rescriptApi: true,      // Core API
    rescriptWrapper: true,  // Pipe-first wrapper
    typescriptDts: true,    // TypeScript types
    typescriptWrapper: true // TypeScript client
  }
};

await generate(config);

Configuration Options

const config = {
  // Required
  specPath: 'https://example.com/api.json',  // URL or local file path
  outputDir: './generated',
  
  // Optional
  strategy: 'SharedBase',           // 'Separate' | 'SharedBase'
  modulePerTag: true,               // Generate one module per API tag
  generateDiffReport: true,         // Generate markdown diff reports
  breakingChangeHandling: 'Warn',   // 'Ignore' | 'Warn' | 'Error'
  includeTags: undefined,           // Filter to specific tags
  excludeTags: undefined,           // Exclude specific tags
  
  // Multi-fork configuration
  forkSpecs: [
    { name: 'cherrypick', specPath: 'https://kokonect.link/api.json' },
  ],
  
  // Output targets
  targets: {
    rescriptApi: true,
    rescriptWrapper: false,
    typescriptDts: false,
    typescriptWrapper: false,
  },

  // Documentation overrides
  generateDocOverrides: false,
  docOverrideDir: './docs/api-overrides',
};

📚 Examples

Detailed examples are available in the examples/ directory:

  • 01-generate-single-spec.mjs: Basic generation from one API spec.
  • 02-compare-specs.mjs: Generate a difference report between two specs.
  • 03-generate-multi-fork.mjs: Advanced usage for multiple API forks with code sharing.

🛠️ Development

npm install
npm run build
npm test

📄 License

This project is licensed under the Mozilla Public License 2.0.